# HG changeset patch # User Nathan Froyd # Date 1535639295 14400 # Node ID 345269b39c6c2d08edebb8225e55c690dc019537 # Parent d4c509ba352a69da563e3d4affcf167edd991255 Bug 1486905 - add a HOST_LINKER variable for cross windows builds; r=dmajor This setup seems to work well enough to enable me to link HOST_SIMPLE_PROGRAMS with an AArch64-cross setup. Necessary library paths are passed to the linker via -LIBPATH and HOST_LDFLAGS rather than letting MSVC fish them out of the environment. The change to HOST_SIMPLE_PROGRAMS to pass HOST_LDFLAGS was necessary for this to work, in addition to the HOST_LINKER changes. diff --git a/build/moz.configure/windows.configure b/build/moz.configure/windows.configure --- a/build/moz.configure/windows.configure +++ b/build/moz.configure/windows.configure @@ -464,18 +464,18 @@ def linker_progs_for(host_or_target): if compiler.type == 'clang-cl': return ('lld-link', 'link') return linker_progs link = check_prog('LINKER', linker_progs_for(target), paths=toolchain_search_path) -# -host_link = check_prog('HOST_LINKER', ('lld-link.exe', 'link.exe'), -# +host_link = check_prog('HOST_LINKER', linker_progs_for(host), +host_link = check_prog('HOST_LINKER', linker_progs_for(host), + paths=toolchain_search_path) add_old_configure_assignment('LINKER', link) # Normally, we'd just have CC, etc. set to absolute paths, but the build system # doesn't currently handle properly the case where the paths contain spaces. # Additionally, there's the issue described in toolchain.configure, in # valid_compiler(). diff --git a/config/rules.mk b/config/rules.mk --- a/config/rules.mk +++ b/config/rules.mk @@ -577,17 +577,17 @@ ifdef ENABLE_STRIP endif ifdef MOZ_POST_PROGRAM_COMMAND $(MOZ_POST_PROGRAM_COMMAND) $@ endif $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) $(call mkdir_deps,$(DEPTH)/dist/host/bin) $(REPORT_BUILD) ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH)) - $(LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) + $(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) ifdef MSMANIFEST_TOOL @if test -f $@.manifest; then \ if test -f '$(srcdir)/$(notdir $@).manifest'; then \ echo 'Embedding manifest from $(srcdir)/$(notdir $@).manifest and $@.manifest'; \ $(MT) -NOLOGO -MANIFEST '$(win_srcdir)/$(notdir $@).manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \ else \ echo 'Embedding manifest from $@.manifest'; \ $(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ @@ -636,17 +636,17 @@ ifdef ENABLE_STRIP endif ifdef MOZ_POST_PROGRAM_COMMAND $(MOZ_POST_PROGRAM_COMMAND) $@ endif $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) $(REPORT_BUILD) ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC)) - $(LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) + $(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) else ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX)) $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXX_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS) else $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_C_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS) endif endif ifndef CROSS_COMPILE @@ -673,18 +673,17 @@ endif $(REPORT_BUILD) $(RM) $@ $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS) $(HOST_SHARED_LIBRARY): $(HOST_OBJS) Makefile $(REPORT_BUILD) $(RM) $@ ifdef _MSC_VER - # /!\ We assume host and target are using the same compiler - $(LINKER) -NOLOGO -DLL -OUT:$@ $(HOST_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) + $(HOST_LINKER) -NOLOGO -DLL -OUT:$@ $(HOST_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) else $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) endif # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files, # so instead of deleting .o files after repacking them into a dylib, we make # symlinks back to the originals. The symlinks are a no-op for stabs debugging, # so no need to conditionalize on OS version or debugging format.