mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Cleanup fix for global initialization (#93)
* Cleanup fix for global initialization * Remove linker script hack * Use v0 symbol mangling * Fix warnings
This commit is contained in:
parent
64c561dc22
commit
ab4ff2dfe0
@ -38,7 +38,7 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
export RUSTFLAGS="$linker -Cpanic=abort -Cdebuginfo=2 -Clto=off -Zpanic-abort-tests -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot"
|
||||
export RUSTFLAGS="$linker -Cpanic=abort -Zsymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zpanic-abort-tests -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot"
|
||||
|
||||
# FIXME(antoyo): remove once the atomic shim is gone
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
|
@ -43,10 +43,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||
// TODO(antoyo): handle non-null-terminated strings.
|
||||
let string = self.context.new_string_literal(&*string);
|
||||
let sym = self.generate_local_symbol_name("str");
|
||||
// NOTE: TLS is always off for a string litteral.
|
||||
// NOTE: string litterals do not have a link section.
|
||||
let global = self.declare_private_global(&sym, self.val_ty(string));
|
||||
global.global_set_initializer_value(string); // TODO: only set if not imported?
|
||||
global.global_set_initializer_value(string);
|
||||
global
|
||||
// TODO(antoyo): set linkage.
|
||||
}
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -63,7 +63,7 @@ use rustc_errors::{ErrorReported, Handler};
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_middle::middle::cstore::EncodedMetadata;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{CrateType, Lto, OptLevel, OutputFilenames};
|
||||
use rustc_session::config::{Lto, OptLevel, OutputFilenames};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::fatal_error::FatalError;
|
||||
@ -106,16 +106,8 @@ impl CodegenBackend for GccCodegenBackend {
|
||||
Ok((codegen_results, work_products))
|
||||
}
|
||||
|
||||
fn link(&self, sess: &Session, mut codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorReported> {
|
||||
fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorReported> {
|
||||
use rustc_codegen_ssa::back::link::link_binary;
|
||||
if let Some(symbols) = codegen_results.crate_info.exported_symbols.get_mut(&CrateType::Dylib) {
|
||||
// TODO:(antoyo): remove when global initializer work without calling a function at runtime.
|
||||
// HACK: since this codegen add some symbols (e.g. __gccGlobalCrateInit) and the UI
|
||||
// tests load libstd.so as a dynamic library, and rustc use a version-script to specify
|
||||
// the symbols visibility, we add * to export all symbols.
|
||||
// It seems other symbols from libstd/libcore are causing some issues here as well.
|
||||
symbols.push("*".to_string());
|
||||
}
|
||||
|
||||
link_binary::<crate::archive::ArArchiveBuilder<'_>>(
|
||||
sess,
|
||||
|
2
test.sh
2
test.sh
@ -171,7 +171,7 @@ git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs
|
||||
git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs
|
||||
rm src/test/ui/llvm-asm/llvm-asm-in-out-operand.rs || true # TODO(antoyo): Enable back this test if I ever implement the llvm_asm! macro.
|
||||
|
||||
RUSTC_ARGS="-Zpanic-abort-tests -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot -Cpanic=abort"
|
||||
RUSTC_ARGS="-Zpanic-abort-tests -Zsymbol-mangling-version=v0 -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot -Cpanic=abort"
|
||||
|
||||
echo "[TEST] rustc test suite"
|
||||
COMPILETEST_FORCE_STAGE0=1 ./x.py test --run always --stage 0 src/test/ui/ --rustc-args "$RUSTC_ARGS"
|
||||
|
Loading…
Reference in New Issue
Block a user