Bug 1365993 - Don't pass mac frameworks to cargo linker. r=froydnj

Procedural macros for rust are compiled as dynamic libraries.
The compiler subsequently loads those libraries at runtime
when it compiles crates which make use of them.

We pass the generic LDFLAGS to our linker wrapper which ensures
cargo links static libraries with the correct flags. However
this also means that any final system dependency libraries
end up linked into the procedural macro dynamic libraries
whether they use them or not.

When building on macOS 10.7, this causes a SIGTRAP when dlopen
calls CFInitialize for system libraries like Cocoa off the main
thread. We believe this is a macOS bug, reported fixed in macOS 10.9.
https://openradar.appspot.com/7209349

Work around the issue by stripping those libraries and Frameworks
from the linker flags we pass to cargo. We could do a more careful
job of parsing and removing all -framework and -lfoo arguments
inside the linker script, but since this is a temporary issue
while we're using older build machines, I thought just stripping
them once in the build system was simpler.

MozReview-Commit-ID: CGXD8ARvojj

--HG--
extra : rebase_source : 33f28e8fbafb43dbdd257d9162a6e792fca79e51
This commit is contained in:
Ralph Giles 2017-05-25 14:49:32 -07:00
Родитель 716a57ca26
Коммит 40e81c774e
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -997,8 +997,11 @@ ifneq (WINNT,$(OS_ARCH))
# some crates's build scripts (!), so disable it for now.
ifndef MOZ_ASAN
ifndef MOZ_TSAN
# Cargo needs the same linker flags as the C/C++ compiler,
# but not the final libraries. Filter those out because they
# cause problems on macOS 10.7; see bug 1365993 for details.
target_cargo_env_vars := \
MOZ_CARGO_WRAP_LDFLAGS="$(LDFLAGS)" \
MOZ_CARGO_WRAP_LDFLAGS="$(filter-out -framework Cocoa -lobjc AudioToolbox ExceptionHandling,$(LDFLAGS))" \
MOZ_CARGO_WRAP_LD="$(CC)" \
$(cargo_linker_env_var)=$(topsrcdir)/build/cargo-linker
endif # MOZ_TSAN