Skip to content

Commit c62e8b4

Browse files
committed
Support TLS with Mach-O too
1 parent 8fc20f7 commit c62e8b4

File tree

6 files changed

+16
-41
lines changed

6 files changed

+16
-41
lines changed

Cargo.lock

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

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" }
4242
cranelift-faerie = { path = "../cranelift/cranelift-faerie" }
4343
cranelift-object = { path = "../cranelift/cranelift-object" }
4444

45-
#[patch.crates-io]
45+
[patch.crates-io]
4646
#gimli = { path = "../" }
47+
object = { path = "./object" }
4748

4849
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
4950
cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" }

crate_patches/regex.patch

-34
This file was deleted.

prepare.sh

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ git clone https://github.com/rust-lang/regex.git || echo "rust-lang/regex has al
99
pushd regex
1010
git checkout -- .
1111
git checkout 341f207c1071f7290e3f228c710817c280c8dca1
12-
git apply ../crate_patches/regex.patch
1312
popd
1413

1514
git clone https://github.com/ebobby/simple-raytracer || echo "ebobby/simple-raytracer has already been cloned"

src/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ fn default_call_conv(sess: &Session) -> CallConv {
250250
}
251251

252252
fn build_isa(sess: &Session, enable_pic: bool) -> Box<dyn isa::TargetIsa + 'static> {
253+
use target_lexicon::BinaryFormat;
254+
255+
let target_triple = crate::target_triple(sess);
256+
253257
let mut flags_builder = settings::builder();
254258
if enable_pic {
255259
flags_builder.enable("is_pic").unwrap();
@@ -268,6 +272,14 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box<dyn isa::TargetIsa + 'stat
268272
)
269273
.unwrap();
270274

275+
let tls_model = match target_triple.binary_format {
276+
BinaryFormat::Elf => "tls_gd",
277+
BinaryFormat::Macho => "macho",
278+
BinaryFormat::Coff => "coff",
279+
_ => "none",
280+
};
281+
flags_builder.set("tls_model", tls_model).unwrap();
282+
271283
// FIXME(CraneStation/cranelift#732) fix LICM in presence of jump tables
272284
/*
273285
use rustc::session::config::OptLevel;
@@ -284,7 +296,6 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box<dyn isa::TargetIsa + 'stat
284296
}
285297
}*/
286298

287-
let target_triple = crate::target_triple(sess);
288299
let flags = settings::Flags::new(flags_builder);
289300
cranelift::codegen::isa::lookup(target_triple)
290301
.unwrap()

test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [[ "$1" == "--release" ]]; then
77
cargo build --release $CG_CLIF_COMPILE_FLAGS
88
else
99
export CHANNEL='debug'
10-
cargo rustc $CG_CLIF_COMPILE_FLAGS --features backend_object -- -Clink-args=-fuse-ld=lld
10+
cargo build $CG_CLIF_COMPILE_FLAGS --features backend_object
1111
fi
1212

1313
source config.sh
@@ -78,7 +78,7 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna"
7878
../cargo.sh clean
7979
# Make sure `[codegen mono items] start` doesn't poison the diff
8080
../cargo.sh build --example shootout-regex-dna
81-
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt
81+
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Threads are not yet" > res.txt
8282
diff -u res.txt examples/regexdna-output.txt
8383

8484
echo "[TEST] rust-lang/regex tests"

0 commit comments

Comments
 (0)