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

Commit

Permalink
Fix cross-compiling to FreeBSD
Browse files Browse the repository at this point in the history
* 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?
  • Loading branch information
alexcrichton authored and pftbest committed Oct 28, 2016
1 parent 989c738 commit fc0dadf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cmake/modules/HandleLLVMOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ endif()

# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# build might work on ELF but fail on MachO/COFF.
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
if(NOT (${TARGET_TRIPLE} MATCHES "darwin" OR
${TARGET_TRIPLE} MATCHES "windows" OR
${TARGET_TRIPLE} MATCHES "mingw" OR
${TARGET_TRIPLE} MATCHES "freebsd" OR
${TARGET_TRIPLE} MATCHES "netbsd" OR
${TARGET_TRIPLE} MATCHES "openbsd") AND
NOT LLVM_USE_SANITIZER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
endif()
Expand Down
2 changes: 1 addition & 1 deletion tools/dsymutil/DwarfLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ PointerIntPair<DeclContext *, 1> DeclContextTree::getChildDeclContext(
if (!ResolvedPath.empty()) {
FileRef = ResolvedPath;
} else {
#ifdef HAVE_REALPATH
#if defined(HAVE_REALPATH) && defined(PATH_MAX)
char RealPath[PATH_MAX + 1];
RealPath[PATH_MAX] = 0;
if (::realpath(File.c_str(), RealPath))
Expand Down

0 comments on commit fc0dadf

Please sign in to comment.