Skip to content

Commit

Permalink
elf+aarch64: enable more tls desc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Feb 26, 2024
1 parent 0011916 commit 22a9d23
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2190,15 +2190,15 @@ fn testTlsDesc(b: *Build, opts: Options) *Step {
fn testTlsDescImport(b: *Build, opts: Options) *Step {
const test_step = b.step("test-elf-tls-desc-import", "");

if (builtin.target.cpu.arch == .aarch64) return skipTestStep(test_step);
if (opts.system_compiler != .gcc) return skipTestStep(test_step);

const dso = cc(b, "a.so", opts);
dso.addCSource(
\\_Thread_local int foo = 5;
\\_Thread_local int bar;
);
dso.addArgs(&.{ "-fPIC", "-shared", "-mtls-dialect=gnu2" });
dso.addArgs(&.{ "-fPIC", "-shared" });
forceTlsDescDialect(dso);

const exe = cc(b, "a.out", opts);
exe.addCSource(
Expand All @@ -2210,9 +2210,10 @@ fn testTlsDescImport(b: *Build, opts: Options) *Step {
\\ printf("%d %d\n", foo, bar);
\\}
);
exe.addArgs(&.{ "-fPIC", "-mtls-dialect=gnu2" });
exe.addArgs(&.{"-fPIC"});
exe.addFileSource(dso.getFile());
exe.addPrefixedDirectorySource("-Wl,-rpath,", dso.getDir());
forceTlsDescDialect(exe);

const run = exe.run();
run.expectStdOutEqual("5 7\n");
Expand All @@ -2224,7 +2225,6 @@ fn testTlsDescImport(b: *Build, opts: Options) *Step {
fn testTlsDescStatic(b: *Build, opts: Options) *Step {
const test_step = b.step("test-elf-tls-desc-static", "");

if (builtin.target.cpu.arch == .aarch64) return skipTestStep(test_step);
if (opts.system_compiler != .gcc or !opts.has_static) return skipTestStep(test_step);

const main_o = cc(b, "main.o", opts);
Expand All @@ -2236,13 +2236,15 @@ fn testTlsDescStatic(b: *Build, opts: Options) *Step {
\\ printf("%d\n", foo);
\\}
);
main_o.addArgs(&.{ "-c", "-fPIC", "-mtls-dialect=gnu2" });
main_o.addArgs(&.{ "-c", "-fPIC" });
forceTlsDescDialect(main_o);

const a_o = cc(b, "a.o", opts);
a_o.addCSource(
\\_Thread_local int foo;
);
a_o.addArgs(&.{ "-c", "-fPIC", "-mtls-dialect=gnu2" });
a_o.addArgs(&.{ "-c", "-fPIC" });
forceTlsDescDialect(a_o);

const exp_stdout = "42\n";

Expand Down

0 comments on commit 22a9d23

Please sign in to comment.