Closed Bug 1164109 Opened 9 years ago Closed 9 years ago

rust code fails to link on macosx because of thread-local storage

Categories

(Firefox Build System :: General, defect)

All
macOS
defect
Not set
normal

Tracking

(firefox41 fixed)

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: rillian, Assigned: rillian)

References

Details

Attachments

(1 file, 3 obsolete files)

On MacOS X Yosemite
$ ./mach gtest rust.*
[...]
 0:05.15 ld: targeted OS version does not support use of thread local variables in __ZN6thread7current20hcfeed7bdf861e757etbE for architecture x86_64
 0:05.15 clang: error: linker command failed with exit code 1 (use -v to see invocation)
 0:05.15 make[2]: *** [XUL] Error 1

I swear this worked last week, but maybe not. Still fine on linux64.
Was the build targeting OSX 10.6 or prior? Currently Rust uses TLS features that were added in 10.7 and it's known to not work on 10.6 and prior, but 10.7+ should all work just fine (which would make this quite suspicious!).
(In reply to Alex Crichton [:acrichto] from comment #1)
> Was the build targeting OSX 10.6 or prior? Currently Rust uses TLS features
> that were added in 10.7 and it's known to not work on 10.6 and prior, but
> 10.7+ should all work just fine (which would make this quite suspicious!).

Does this mean that Rust cannot target OSX 10.6 at all? Or does Rust have an issue with 10.6 only if we're using TLS?

:gps, would this be a problem for Firefox integration?
Yes this means that the standard library will not target 10.6 right now. Note that this is the only known incompatibility with 10.6, and there are likely ways to work around it, so this is not a fundamental issue, it will just require some work on our side.
Attached patch Incude -lpthread for gtest (obsolete) — Splinter Review
Adding an explicit -lpthread resolves the issue.
Assignee: nobody → giles
Attachment #8604802 - Flags: review?(ted)
Comment on attachment 8604802 [details] [diff] [review]
Incude -lpthread for gtest

Nevermind.
Attachment #8604802 - Attachment is obsolete: true
Attachment #8604802 - Flags: review?(ted)
Thanks, Alex. I couldn't figure out what was triggering the error message. I guess the linker recognizes the tls-related pthread calls?

In any case, 'ac_add_options --enable-macos-target=10.7' does resolve the issue for me.
(In reply to Ralph Giles (:rillian) from comment #7)
> I guess the linker recognizes the tls-related pthread calls?

The current implementation of thread local variables on OSX actually involves a few compiler attributes and avoids pthread entirely, but it looks like the OSX linker is smart enough to know that when you're targeting an older version of OSX that they won't work correctly.

> In any case, 'ac_add_options --enable-macos-target=10.7' does resolve the
> issue for me.

Good to hear!
Add a configure check to prevent building with the unsupported configuration until we can find a better work-around.
Attachment #8604930 - Flags: review?(ted)
How much of a hindrance is it that the Rust standard library doesn't work on OSX 10.6 right now? Should we try to prioritize compliance, or is it just a "nice to have"?
At the moment, 10.6 support is "this needs to work to ship Rust code with Firefox".
Firefox has more users on OSX 10.6 than Linux, iirc, so if you want code to ship in Firefox on OSX, it needs to work on 10.6.
Thanks for the clarifications! I'll try to investigate soon how hard it would be to lift this blocker for running on 10.6.
OS: Unspecified → Mac OS X
Hardware: Unspecified → All
Comment on attachment 8604930 [details] [diff] [review]
Require MacOS X 10.7 or later when compiling rust

Review of attachment 8604930 [details] [diff] [review]:
-----------------------------------------------------------------

If you haven't already, please file a bug on the root issue here so that we can make that block shipping this with Firefox (whether the decision is "drop 10.6 support" or "support 10.6 in Rust").
Attachment #8604930 - Flags: review?(ted) → review+
Move the 'checking' message inside the conditional to avoid misleading logs. Carrying forward r=ted.
Attachment #8604930 - Attachment is obsolete: true
Blocks: 1166996
https://hg.mozilla.org/mozilla-central/rev/33e255599053
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
I tried to trace the mp4parser rust code but got similar error on m-c (286303:eb25b90a05c1) today.

11:35.33 ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
11:35.33 ld: targeted OS version does not support use of thread local variables in __ZN10sys_common11thread_info14current_thread20h67a0745d7f70577eJAsE for architecture x86_64
11:35.33 clang: error: linker command failed with exit code 1 (use -v to see invocation)
11:35.33 make[5]: *** [XUL] Error 1
11:35.33 make[4]: *** [toolkit/library/target] Error 2
11:35.33 make[4]: *** Waiting for unfinished jobs....
11:35.33 jsapi-tests
11:36.14 ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
11:37.51 ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
11:37.52 make[3]: *** [compile] Error 2
11:37.52 make[2]: *** [default] Error 2
11:37.52 make[1]: *** [realbuild] Error 2
11:37.52 make: *** [build] Error 2
11:37.57 410 compiler warnings present.


My .mozconfig is:

ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --enable-rust


Build environment is:

OS X 10.11.3
rustc 1.6.0 (c30b771ad 2016-01-19)
xcode 7.2.1


Any suggestion?
(In reply to Alfredo Yang (:alfredo) from comment #19)
> I tried to trace the mp4parser rust code but got similar error on m-c
> (286303:eb25b90a05c1) today.

Alfredo, did you ever find a resolution? I just ran into the same problem today.
(In reply to Jonathan Chan [:jyc] from comment #20)
> (In reply to Alfredo Yang (:alfredo) from comment #19)
> > I tried to trace the mp4parser rust code but got similar error on m-c
> > (286303:eb25b90a05c1) today.
> 
> Alfredo, did you ever find a resolution? I just ran into the same problem
> today.

No. :(
(In reply to Jonathan Chan [:jyc] from comment #20)
> (In reply to Alfredo Yang (:alfredo) from comment #19)
> > I tried to trace the mp4parser rust code but got similar error on m-c
> > (286303:eb25b90a05c1) today.
> 
> Alfredo, did you ever find a resolution? I just ran into the same problem
> today.

https://bugzilla.mozilla.org/show_bug.cgi?id=1188030#c14

You can try it, it works on my laptop.
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: