Skip to content

Commit 3252355

Browse files
authored
Merge pull request #440 from rust-lang/use-default-mangling
Use the default rust mangling
2 parents 1d171ae + e116cb7 commit 3252355

File tree

8 files changed

+57
-41
lines changed

8 files changed

+57
-41
lines changed

.github/workflows/ci.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
libgccjit_version:
22-
- { gcc: "libgccjit.so", artifacts_branch: "master" }
23-
- { gcc: "libgccjit_without_int128.so", artifacts_branch: "master-without-128bit-integers" }
22+
- { gcc: "gcc-13.deb" }
23+
- { gcc: "gcc-13-without-int128.deb" }
2424
commands: [
2525
"--mini-tests",
2626
"--std-tests",
@@ -49,10 +49,19 @@ jobs:
4949
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
5050
run: sudo apt-get install ninja-build ripgrep llvm-14-tools
5151

52+
- name: Download artifact
53+
run: curl -LO https://github.com/antoyo/gcc/releases/latest/download/${{ matrix.libgccjit_version.gcc }}
54+
55+
- name: Setup path to libgccjit
56+
run: |
57+
sudo dpkg --force-overwrite -i ${{ matrix.libgccjit_version.gcc }}
58+
echo 'gcc-path = "/usr/lib/"' > config.toml
59+
5260
- name: Set env
5361
run: |
5462
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
55-
echo 'download-gccjit = true' > config.toml
63+
echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
64+
echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
5665
5766
#- name: Cache rust repository
5867
## We only clone the rust repository for rustc tests
@@ -67,15 +76,6 @@ jobs:
6776
run: |
6877
./y.sh prepare --only-libcore
6978
./y.sh build
70-
71-
- name: Set env (part 2)
72-
run: |
73-
# Set the `LD_LIBRARY_PATH` and `LIBRARY_PATH` env variables...
74-
echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
75-
echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
76-
77-
- name: Build (part 2)
78-
run: |
7979
cargo test
8080
./y.sh clean all
8181

.github/workflows/stdarch.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,24 @@ jobs:
5050
sudo ln -s /usr/share/intel-sde/sde /usr/bin/sde
5151
sudo ln -s /usr/share/intel-sde/sde64 /usr/bin/sde64
5252
53-
- name: Download artifact
54-
run: curl -LO https://github.com/antoyo/gcc/releases/latest/download/gcc-13.deb
55-
56-
- name: Setup path to libgccjit
57-
run: |
58-
sudo dpkg --force-overwrite -i gcc-13.deb
59-
echo 'gcc-path = "/usr/lib/"' > config.toml
60-
6153
- name: Set env
6254
run: |
6355
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
64-
echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
65-
echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
56+
echo 'download-gccjit = true' > config.toml
6657
6758
- name: Build
6859
run: |
6960
./y.sh prepare --only-libcore
7061
./y.sh build --release --release-sysroot
62+
63+
- name: Set env (part 2)
64+
run: |
65+
# Set the `LD_LIBRARY_PATH` and `LIBRARY_PATH` env variables...
66+
echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
67+
echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
68+
69+
- name: Build (part 2)
70+
run: |
7171
cargo test
7272
7373
- name: Clean

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_system/src/config.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,11 @@ impl ConfigInfo {
415415
if let Some(linker) = linker {
416416
rustflags.push(linker.to_string());
417417
}
418+
419+
#[cfg(not(feature="master"))]
420+
rustflags.push("-Csymbol-mangling-version=v0".to_string());
421+
418422
rustflags.extend_from_slice(&[
419-
"-Csymbol-mangling-version=v0".to_string(),
420423
"-Cdebuginfo=2".to_string(),
421424
format!("-Zcodegen-backend={}", self.cg_backend_path),
422425
]);

build_system/src/test.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,21 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
612612

613613
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
614614

615+
let rustc_args =
616+
&format!(
617+
r#"-Zpanic-abort-tests \
618+
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
619+
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort"#,
620+
pwd = std::env::current_dir()
621+
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
622+
.display(),
623+
channel = args.config_info.channel.as_str(),
624+
dylib_ext = args.config_info.dylib_ext,
625+
);
626+
627+
#[cfg(not(feature="master"))]
628+
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
629+
615630
run_command_with_env(
616631
&[
617632
&"./x.py",
@@ -622,17 +637,7 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
622637
&"0",
623638
&"tests/assembly/asm",
624639
&"--rustc-args",
625-
&format!(
626-
r#"-Zpanic-abort-tests -Csymbol-mangling-version=v0 \
627-
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
628-
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort"#,
629-
pwd = std::env::current_dir()
630-
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
631-
.display(),
632-
channel = args.config_info.channel.as_str(),
633-
dylib_ext = args.config_info.dylib_ext,
634-
)
635-
.as_str(),
640+
&rustc_args,
636641
],
637642
Some(&rust_dir),
638643
Some(&env),
@@ -1065,12 +1070,15 @@ where
10651070
println!("[TEST] rustc test suite");
10661071
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
10671072
let rustc_args = format!(
1068-
"{} -Csymbol-mangling-version=v0 -Zcodegen-backend={} --sysroot {}",
1073+
"{} -Zcodegen-backend={} --sysroot {}",
10691074
env.get("TEST_FLAGS").unwrap_or(&String::new()),
10701075
args.config_info.cg_backend_path,
10711076
args.config_info.sysroot_path,
10721077
);
10731078

1079+
#[cfg(not(feature="master"))]
1080+
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
1081+
10741082
env.get_mut("RUSTFLAGS").unwrap().clear();
10751083
run_command_with_output_and_env(
10761084
&[

libgccjit.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2fc8940e1
1+
cdd897840

src/declare.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll
125125
let params: Vec<_> = param_types.into_iter().enumerate()
126126
.map(|(index, param)| cx.context.new_parameter(None, *param, &format!("param{}", index))) // TODO(antoyo): set name.
127127
.collect();
128-
let func = cx.context.new_function(None, cx.linkage.get(), return_type, &params, mangle_name(name), variadic);
128+
#[cfg(not(feature="master"))]
129+
let name = mangle_name(name);
130+
let func = cx.context.new_function(None, cx.linkage.get(), return_type, &params, &name, variadic);
129131
cx.functions.borrow_mut().insert(name.to_string(), func);
130132

131133
#[cfg(feature="master")]
@@ -179,8 +181,10 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll
179181
}
180182

181183
// FIXME(antoyo): this is a hack because libgccjit currently only supports alpha, num and _.
182-
// Unsupported characters: `$` and `.`.
183-
pub fn mangle_name(name: &str) -> String {
184+
// Unsupported characters: `$`, `.` and `*`.
185+
// FIXME(antoyo): `*` might not be expected: https://github.com/rust-lang/rust/issues/116979#issuecomment-1840926865
186+
#[cfg(not(feature="master"))]
187+
fn mangle_name(name: &str) -> String {
184188
name.replace(|char: char| {
185189
if !char.is_alphanumeric() && char != '_' {
186190
debug_assert!("$.*".contains(char), "Unsupported char in function name {}: {}", name, char);

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> {
255255
}
256256
#[cfg(feature="master")]
257257
{
258+
context.set_allow_special_chars_in_func_names(true);
258259
let version = Version::get();
259260
let version = format!("{}.{}.{}", version.major, version.minor, version.patch);
260261
context.set_output_ident(&format!("rustc version {} with libgccjit {}",

0 commit comments

Comments
 (0)