Skip to content

Commit 9383e9c

Browse files
Mariusz Ceiernico
authored andcommitted
Fix lld macho standalone build by including llvm/Config/llvm-config.h instead of llvm/Config/config.h
lld/MachO/Driver.cpp and lld/MachO/SyntheticSections.cpp include llvm/Config/config.h which doesn't exist when building standalone lld. This patch replaces llvm/Config/config.h include with llvm/Config/llvm-config.h just like it is in lld/ELF/Driver.cpp and HAVE_LIBXAR with LLVM_HAVE_LIXAR and moves LLVM_HAVE_LIBXAR from config.h to llvm-config.h Also it adds LLVM_HAVE_LIBXAR to LLVMConfig.cmake and links liblldMachO2.so with XAR_LIB if LLVM_HAVE_LIBXAR is set. Differential Revision: https://reviews.llvm.org/D102084
1 parent 66963bf commit 9383e9c

18 files changed

Lines changed: 43 additions & 36 deletions

File tree

‎lld/CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
110110
set(LLVM_INCLUDE_TESTS OFF)
111111
endif()
112112
endif()
113+
114+
if(LLVM_HAVE_LIBXAR)
115+
set(XAR_LIB xar)
116+
endif()
113117
endif()
114118

115119
set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

‎lld/MachO/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ add_lld_library(lldMachO2
4848
LINK_LIBS
4949
lldCommon
5050
${LLVM_PTHREAD_LIB}
51+
${XAR_LIB}
5152

5253
DEPENDS
5354
MachOOptionsTableGen

‎lld/MachO/Driver.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "llvm/ADT/StringRef.h"
3232
#include "llvm/BinaryFormat/MachO.h"
3333
#include "llvm/BinaryFormat/Magic.h"
34-
#include "llvm/Config/config.h"
34+
#include "llvm/Config/llvm-config.h"
3535
#include "llvm/LTO/LTO.h"
3636
#include "llvm/Object/Archive.h"
3737
#include "llvm/Option/ArgList.h"
@@ -992,7 +992,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
992992
args.hasFlag(OPT_encryptable, OPT_no_encryption,
993993
is_contained(encryptablePlatforms, config->platform()));
994994

995-
#ifndef HAVE_LIBXAR
995+
#ifndef LLVM_HAVE_LIBXAR
996996
if (config->emitBitcodeBundle)
997997
error("-bitcode_bundle unsupported because LLD wasn't built with libxar");
998998
#endif

‎lld/MachO/SyntheticSections.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "lld/Common/ErrorHandler.h"
2121
#include "lld/Common/Memory.h"
2222
#include "llvm/ADT/STLExtras.h"
23-
#include "llvm/Config/config.h"
23+
#include "llvm/Config/llvm-config.h"
2424
#include "llvm/Support/EndianStream.h"
2525
#include "llvm/Support/FileSystem.h"
2626
#include "llvm/Support/LEB128.h"
@@ -31,7 +31,7 @@
3131
#include <sys/mman.h>
3232
#endif
3333

34-
#ifdef HAVE_LIBXAR
34+
#ifdef LLVM_HAVE_LIBXAR
3535
#include <fcntl.h>
3636
#include <xar/xar.h>
3737
#endif
@@ -1036,7 +1036,7 @@ class ErrorCodeWrapper {
10361036
} while (0);
10371037

10381038
void BitcodeBundleSection::finalize() {
1039-
#ifdef HAVE_LIBXAR
1039+
#ifdef LLVM_HAVE_LIBXAR
10401040
using namespace llvm::sys::fs;
10411041
CHECK_EC(createTemporaryFile("bitcode-bundle", "xar", xarPath));
10421042

@@ -1048,7 +1048,7 @@ void BitcodeBundleSection::finalize() {
10481048
CHECK_EC(xar_close(xar));
10491049

10501050
file_size(xarPath, xarSize);
1051-
#endif // defined(HAVE_LIBXAR)
1051+
#endif // defined(LLVM_HAVE_LIBXAR)
10521052
}
10531053

10541054
void BitcodeBundleSection::writeTo(uint8_t *buf) const {

‎lld/test/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ llvm_canonicalize_cmake_booleans(
1111
LLVM_ENABLE_ZLIB
1212
LLVM_ENABLE_LIBXML2
1313
LLD_DEFAULT_LD_LLD_IS_MINGW
14-
HAVE_LIBXAR
14+
LLVM_HAVE_LIBXAR
1515
)
1616

1717
configure_lit_site_cfg(

‎lld/test/lit.site.cfg.py.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config.lld_tools_dir = "@LLD_TOOLS_DIR@"
1515
config.target_triple = "@TARGET_TRIPLE@"
1616
config.python_executable = "@Python3_EXECUTABLE@"
1717
config.have_zlib = @LLVM_ENABLE_ZLIB@
18-
config.have_libxar = @HAVE_LIBXAR@
18+
config.have_libxar = @LLVM_HAVE_LIBXAR@
1919
config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
2020
config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@
2121
config.ld_lld_default_mingw = @LLD_DEFAULT_LD_LLD_IS_MINGW@

‎lld/tools/lld/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ target_link_libraries(lld
2020
lldWasm
2121
)
2222

23-
if(HAVE_LIBXAR)
23+
if(LLVM_HAVE_LIBXAR)
2424
target_link_libraries(lld PRIVATE ${XAR_LIB})
2525
endif()
2626

‎llvm/cmake/config-ix.cmake‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ else()
189189
set(LLVM_ENABLE_TERMINFO 0)
190190
endif()
191191

192-
check_library_exists(xar xar_open "" HAVE_LIBXAR)
193-
if(HAVE_LIBXAR)
192+
check_library_exists(xar xar_open "" LLVM_HAVE_LIBXAR)
193+
if(LLVM_HAVE_LIBXAR)
194194
set(XAR_LIB xar)
195195
endif()
196196

‎llvm/cmake/modules/LLVMConfig.cmake.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ set(LLVM_ENABLE_SHARED_LIBS @BUILD_SHARED_LIBS@)
111111
set(LLVM_DEFAULT_EXTERNAL_LIT "@LLVM_CONFIG_DEFAULT_EXTERNAL_LIT@")
112112
set(LLVM_LIT_ARGS "@LLVM_LIT_ARGS@")
113113

114+
set(LLVM_HAVE_LIBXAR "@LLVM_HAVE_LIBXAR@")
115+
114116
if(NOT TARGET LLVMSupport)
115117
@LLVM_CONFIG_INCLUDE_EXPORTS@
116118
@llvm_config_include_buildtree_only_exports@

‎llvm/include/llvm/Config/config.h.cmake‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@
220220
/* Define if the setupterm() function is supported this platform. */
221221
#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
222222

223-
/* Define if the xar_open() function is supported this platform. */
224-
#cmakedefine HAVE_LIBXAR ${HAVE_LIBXAR}
225-
226223
/* Define to 1 if you have the <termios.h> header file. */
227224
#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
228225

0 commit comments

Comments
 (0)