rust/tests/run-make/lto-long-filenames/rmake.rs
Pierre Tardy c6acffeb78 fix panic when rustc tries to reduce intermediate filenames length with multi byte chars
The issue cannot be reproduced with the former testcase of creating external crates because
rust refuses to use "external crate 28_找出字符串中第一个匹配项的下标"
because it is not a valid indentifier (starts with number, and contain non ascii chars)

But still using 28_找出字符串中第一个匹配项的下标.rs as a filename is accepted by previous rustc releases
So we consider it valid, and add an integration test for it to catch any regression on other code related to non ascii filenames.
2025-10-24 16:20:29 +02:00

30 lines
1.6 KiB
Rust

// This file has very long lines, but there is no way to avoid it as we are testing
// long crate names. so:
// ignore-tidy-linelength
// A variant of the smoke test to check that link time optimization
// (LTO) is accepted by the compiler, and that
// passing its various flags still results in successful compilation, even for very long crate names.
// See https://github.com/rust-lang/rust/issues/49914
//@ ignore-cross-compile
use run_make_support::{rfs, rustc};
// This test make sure we don't get such following error:
// error: could not write output to generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name.generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name.9384edb61bfd127c-cgu.0.rcgu.o: File name too long
// as reported in issue #49914
fn main() {
let lto_flags = ["-Clto", "-Clto=yes", "-Clto=off", "-Clto=thin", "-Clto=fat"];
let aux_file = "generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name.rs";
// The auxiliary file is used to test long crate names.
// The file name is intentionally long to test the handling of long filenames.
// We don't commit it to avoid issues with Windows paths which have known limitations for the full path length.
// Posix usually only have a limit for the length of the file name.
rfs::write(aux_file, "#![crate_type = \"rlib\"]\n");
for flag in lto_flags {
rustc().input(aux_file).arg(flag).run();
rustc().input("main.rs").arg(flag).run();
}
}