Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit fc0dadf

Browse files
alexcrichtonpftbest
authored andcommitted
Fix cross-compiling to FreeBSD
* When testing whether we need to pass `-Wl,-z,defs` the cmake files currently tests for FreeBSD, but only if the host system is FreeBSD. Instead we should test whether the target that we're compiling is FreeBSD so we correctly deduce that it should not be passed. * The `PATH_MAX` constant is defined in a different place for the dsymutil tool, so we just config that code out for now as it apparently doesn't include the right header?
1 parent 989c738 commit fc0dadf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

cmake/modules/HandleLLVMOptions.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ endif()
102102

103103
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
104104
# build might work on ELF but fail on MachO/COFF.
105-
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
106-
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
107-
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
105+
if(NOT (${TARGET_TRIPLE} MATCHES "darwin" OR
106+
${TARGET_TRIPLE} MATCHES "windows" OR
107+
${TARGET_TRIPLE} MATCHES "mingw" OR
108+
${TARGET_TRIPLE} MATCHES "freebsd" OR
109+
${TARGET_TRIPLE} MATCHES "netbsd" OR
110+
${TARGET_TRIPLE} MATCHES "openbsd") AND
108111
NOT LLVM_USE_SANITIZER)
109112
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
110113
endif()

tools/dsymutil/DwarfLinker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ PointerIntPair<DeclContext *, 1> DeclContextTree::getChildDeclContext(
16451645
if (!ResolvedPath.empty()) {
16461646
FileRef = ResolvedPath;
16471647
} else {
1648-
#ifdef HAVE_REALPATH
1648+
#if defined(HAVE_REALPATH) && defined(PATH_MAX)
16491649
char RealPath[PATH_MAX + 1];
16501650
RealPath[PATH_MAX] = 0;
16511651
if (::realpath(File.c_str(), RealPath))

0 commit comments

Comments
 (0)