Merge pull request #440 from rust-lang/use-default-mangling
Use the default rust mangling
This commit is contained in:
commit
32523557e7
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@ -19,8 +19,8 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
libgccjit_version:
|
libgccjit_version:
|
||||||
- { gcc: "libgccjit.so", artifacts_branch: "master" }
|
- { gcc: "gcc-13.deb" }
|
||||||
- { gcc: "libgccjit_without_int128.so", artifacts_branch: "master-without-128bit-integers" }
|
- { gcc: "gcc-13-without-int128.deb" }
|
||||||
commands: [
|
commands: [
|
||||||
"--mini-tests",
|
"--mini-tests",
|
||||||
"--std-tests",
|
"--std-tests",
|
||||||
@ -49,10 +49,19 @@ jobs:
|
|||||||
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
|
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
|
||||||
run: sudo apt-get install ninja-build ripgrep llvm-14-tools
|
run: sudo apt-get install ninja-build ripgrep llvm-14-tools
|
||||||
|
|
||||||
|
- name: Download artifact
|
||||||
|
run: curl -LO https://github.com/antoyo/gcc/releases/latest/download/${{ matrix.libgccjit_version.gcc }}
|
||||||
|
|
||||||
|
- name: Setup path to libgccjit
|
||||||
|
run: |
|
||||||
|
sudo dpkg --force-overwrite -i ${{ matrix.libgccjit_version.gcc }}
|
||||||
|
echo 'gcc-path = "/usr/lib/"' > config.toml
|
||||||
|
|
||||||
- name: Set env
|
- name: Set env
|
||||||
run: |
|
run: |
|
||||||
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
|
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
|
||||||
echo 'download-gccjit = true' > config.toml
|
echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
|
||||||
|
echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
|
||||||
|
|
||||||
#- name: Cache rust repository
|
#- name: Cache rust repository
|
||||||
## We only clone the rust repository for rustc tests
|
## We only clone the rust repository for rustc tests
|
||||||
@ -67,15 +76,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
./y.sh prepare --only-libcore
|
./y.sh prepare --only-libcore
|
||||||
./y.sh build
|
./y.sh build
|
||||||
|
|
||||||
- name: Set env (part 2)
|
|
||||||
run: |
|
|
||||||
# Set the `LD_LIBRARY_PATH` and `LIBRARY_PATH` env variables...
|
|
||||||
echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
|
|
||||||
echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build (part 2)
|
|
||||||
run: |
|
|
||||||
cargo test
|
cargo test
|
||||||
./y.sh clean all
|
./y.sh clean all
|
||||||
|
|
||||||
|
20
.github/workflows/stdarch.yml
vendored
20
.github/workflows/stdarch.yml
vendored
@ -50,24 +50,24 @@ jobs:
|
|||||||
sudo ln -s /usr/share/intel-sde/sde /usr/bin/sde
|
sudo ln -s /usr/share/intel-sde/sde /usr/bin/sde
|
||||||
sudo ln -s /usr/share/intel-sde/sde64 /usr/bin/sde64
|
sudo ln -s /usr/share/intel-sde/sde64 /usr/bin/sde64
|
||||||
|
|
||||||
- name: Download artifact
|
|
||||||
run: curl -LO https://github.com/antoyo/gcc/releases/latest/download/gcc-13.deb
|
|
||||||
|
|
||||||
- name: Setup path to libgccjit
|
|
||||||
run: |
|
|
||||||
sudo dpkg --force-overwrite -i gcc-13.deb
|
|
||||||
echo 'gcc-path = "/usr/lib/"' > config.toml
|
|
||||||
|
|
||||||
- name: Set env
|
- name: Set env
|
||||||
run: |
|
run: |
|
||||||
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
|
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
|
||||||
echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
|
echo 'download-gccjit = true' > config.toml
|
||||||
echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
./y.sh prepare --only-libcore
|
./y.sh prepare --only-libcore
|
||||||
./y.sh build --release --release-sysroot
|
./y.sh build --release --release-sysroot
|
||||||
|
|
||||||
|
- name: Set env (part 2)
|
||||||
|
run: |
|
||||||
|
# Set the `LD_LIBRARY_PATH` and `LIBRARY_PATH` env variables...
|
||||||
|
echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
|
||||||
|
echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build (part 2)
|
||||||
|
run: |
|
||||||
cargo test
|
cargo test
|
||||||
|
|
||||||
- name: Clean
|
- name: Clean
|
||||||
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -80,7 +80,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit"
|
name = "gccjit"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/antoyo/gccjit.rs#e6109eb8b7ced60b5191e65b34954d04d4abeaec"
|
source = "git+https://github.com/antoyo/gccjit.rs#4b7aba76891e6436984f7f098fe92824d95194d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gccjit_sys",
|
"gccjit_sys",
|
||||||
]
|
]
|
||||||
@ -88,7 +88,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit_sys"
|
name = "gccjit_sys"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/antoyo/gccjit.rs#e6109eb8b7ced60b5191e65b34954d04d4abeaec"
|
source = "git+https://github.com/antoyo/gccjit.rs#4b7aba76891e6436984f7f098fe92824d95194d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
@ -415,8 +415,11 @@ pub fn setup(
|
|||||||
if let Some(linker) = linker {
|
if let Some(linker) = linker {
|
||||||
rustflags.push(linker.to_string());
|
rustflags.push(linker.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature="master"))]
|
||||||
|
rustflags.push("-Csymbol-mangling-version=v0".to_string());
|
||||||
|
|
||||||
rustflags.extend_from_slice(&[
|
rustflags.extend_from_slice(&[
|
||||||
"-Csymbol-mangling-version=v0".to_string(),
|
|
||||||
"-Cdebuginfo=2".to_string(),
|
"-Cdebuginfo=2".to_string(),
|
||||||
format!("-Zcodegen-backend={}", self.cg_backend_path),
|
format!("-Zcodegen-backend={}", self.cg_backend_path),
|
||||||
]);
|
]);
|
||||||
|
@ -612,6 +612,21 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
|
|||||||
|
|
||||||
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
|
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
|
||||||
|
|
||||||
|
let rustc_args =
|
||||||
|
&format!(
|
||||||
|
r#"-Zpanic-abort-tests \
|
||||||
|
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
|
||||||
|
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort"#,
|
||||||
|
pwd = std::env::current_dir()
|
||||||
|
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
|
||||||
|
.display(),
|
||||||
|
channel = args.config_info.channel.as_str(),
|
||||||
|
dylib_ext = args.config_info.dylib_ext,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(not(feature="master"))]
|
||||||
|
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
|
||||||
|
|
||||||
run_command_with_env(
|
run_command_with_env(
|
||||||
&[
|
&[
|
||||||
&"./x.py",
|
&"./x.py",
|
||||||
@ -622,17 +637,7 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
|
|||||||
&"0",
|
&"0",
|
||||||
&"tests/assembly/asm",
|
&"tests/assembly/asm",
|
||||||
&"--rustc-args",
|
&"--rustc-args",
|
||||||
&format!(
|
&rustc_args,
|
||||||
r#"-Zpanic-abort-tests -Csymbol-mangling-version=v0 \
|
|
||||||
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
|
|
||||||
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort"#,
|
|
||||||
pwd = std::env::current_dir()
|
|
||||||
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
|
|
||||||
.display(),
|
|
||||||
channel = args.config_info.channel.as_str(),
|
|
||||||
dylib_ext = args.config_info.dylib_ext,
|
|
||||||
)
|
|
||||||
.as_str(),
|
|
||||||
],
|
],
|
||||||
Some(&rust_dir),
|
Some(&rust_dir),
|
||||||
Some(&env),
|
Some(&env),
|
||||||
@ -1065,12 +1070,15 @@ fn file_handling(file_path: &Path) -> Result<(), String> {
|
|||||||
println!("[TEST] rustc test suite");
|
println!("[TEST] rustc test suite");
|
||||||
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
|
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
|
||||||
let rustc_args = format!(
|
let rustc_args = format!(
|
||||||
"{} -Csymbol-mangling-version=v0 -Zcodegen-backend={} --sysroot {}",
|
"{} -Zcodegen-backend={} --sysroot {}",
|
||||||
env.get("TEST_FLAGS").unwrap_or(&String::new()),
|
env.get("TEST_FLAGS").unwrap_or(&String::new()),
|
||||||
args.config_info.cg_backend_path,
|
args.config_info.cg_backend_path,
|
||||||
args.config_info.sysroot_path,
|
args.config_info.sysroot_path,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(not(feature="master"))]
|
||||||
|
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
|
||||||
|
|
||||||
env.get_mut("RUSTFLAGS").unwrap().clear();
|
env.get_mut("RUSTFLAGS").unwrap().clear();
|
||||||
run_command_with_output_and_env(
|
run_command_with_output_and_env(
|
||||||
&[
|
&[
|
||||||
|
@ -1 +1 @@
|
|||||||
2fc8940e1
|
cdd897840
|
||||||
|
@ -125,7 +125,9 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll
|
|||||||
let params: Vec<_> = param_types.into_iter().enumerate()
|
let params: Vec<_> = param_types.into_iter().enumerate()
|
||||||
.map(|(index, param)| cx.context.new_parameter(None, *param, &format!("param{}", index))) // TODO(antoyo): set name.
|
.map(|(index, param)| cx.context.new_parameter(None, *param, &format!("param{}", index))) // TODO(antoyo): set name.
|
||||||
.collect();
|
.collect();
|
||||||
let func = cx.context.new_function(None, cx.linkage.get(), return_type, ¶ms, mangle_name(name), variadic);
|
#[cfg(not(feature="master"))]
|
||||||
|
let name = mangle_name(name);
|
||||||
|
let func = cx.context.new_function(None, cx.linkage.get(), return_type, ¶ms, &name, variadic);
|
||||||
cx.functions.borrow_mut().insert(name.to_string(), func);
|
cx.functions.borrow_mut().insert(name.to_string(), func);
|
||||||
|
|
||||||
#[cfg(feature="master")]
|
#[cfg(feature="master")]
|
||||||
@ -179,8 +181,10 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(antoyo): this is a hack because libgccjit currently only supports alpha, num and _.
|
// FIXME(antoyo): this is a hack because libgccjit currently only supports alpha, num and _.
|
||||||
// Unsupported characters: `$` and `.`.
|
// Unsupported characters: `$`, `.` and `*`.
|
||||||
pub fn mangle_name(name: &str) -> String {
|
// FIXME(antoyo): `*` might not be expected: https://github.com/rust-lang/rust/issues/116979#issuecomment-1840926865
|
||||||
|
#[cfg(not(feature="master"))]
|
||||||
|
fn mangle_name(name: &str) -> String {
|
||||||
name.replace(|char: char| {
|
name.replace(|char: char| {
|
||||||
if !char.is_alphanumeric() && char != '_' {
|
if !char.is_alphanumeric() && char != '_' {
|
||||||
debug_assert!("$.*".contains(char), "Unsupported char in function name {}: {}", name, char);
|
debug_assert!("$.*".contains(char), "Unsupported char in function name {}: {}", name, char);
|
||||||
|
@ -255,6 +255,7 @@ fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> {
|
|||||||
}
|
}
|
||||||
#[cfg(feature="master")]
|
#[cfg(feature="master")]
|
||||||
{
|
{
|
||||||
|
context.set_allow_special_chars_in_func_names(true);
|
||||||
let version = Version::get();
|
let version = Version::get();
|
||||||
let version = format!("{}.{}.{}", version.major, version.minor, version.patch);
|
let version = format!("{}.{}.{}", version.major, version.minor, version.patch);
|
||||||
context.set_output_ident(&format!("rustc version {} with libgccjit {}",
|
context.set_output_ident(&format!("rustc version {} with libgccjit {}",
|
||||||
|
Loading…
Reference in New Issue
Block a user