forked from OSchip/llvm-project
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
This commit is contained in:
parent
66963bf381
commit
9383e9c1e6
|
@ -110,6 +110,10 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
set(LLVM_INCLUDE_TESTS OFF)
|
set(LLVM_INCLUDE_TESTS OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LLVM_HAVE_LIBXAR)
|
||||||
|
set(XAR_LIB xar)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
|
@ -48,6 +48,7 @@ add_lld_library(lldMachO2
|
||||||
LINK_LIBS
|
LINK_LIBS
|
||||||
lldCommon
|
lldCommon
|
||||||
${LLVM_PTHREAD_LIB}
|
${LLVM_PTHREAD_LIB}
|
||||||
|
${XAR_LIB}
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
MachOOptionsTableGen
|
MachOOptionsTableGen
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/BinaryFormat/MachO.h"
|
#include "llvm/BinaryFormat/MachO.h"
|
||||||
#include "llvm/BinaryFormat/Magic.h"
|
#include "llvm/BinaryFormat/Magic.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/llvm-config.h"
|
||||||
#include "llvm/LTO/LTO.h"
|
#include "llvm/LTO/LTO.h"
|
||||||
#include "llvm/Object/Archive.h"
|
#include "llvm/Object/Archive.h"
|
||||||
#include "llvm/Option/ArgList.h"
|
#include "llvm/Option/ArgList.h"
|
||||||
|
@ -992,7 +992,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
|
||||||
args.hasFlag(OPT_encryptable, OPT_no_encryption,
|
args.hasFlag(OPT_encryptable, OPT_no_encryption,
|
||||||
is_contained(encryptablePlatforms, config->platform()));
|
is_contained(encryptablePlatforms, config->platform()));
|
||||||
|
|
||||||
#ifndef HAVE_LIBXAR
|
#ifndef LLVM_HAVE_LIBXAR
|
||||||
if (config->emitBitcodeBundle)
|
if (config->emitBitcodeBundle)
|
||||||
error("-bitcode_bundle unsupported because LLD wasn't built with libxar");
|
error("-bitcode_bundle unsupported because LLD wasn't built with libxar");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "lld/Common/ErrorHandler.h"
|
#include "lld/Common/ErrorHandler.h"
|
||||||
#include "lld/Common/Memory.h"
|
#include "lld/Common/Memory.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/llvm-config.h"
|
||||||
#include "llvm/Support/EndianStream.h"
|
#include "llvm/Support/EndianStream.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/LEB128.h"
|
#include "llvm/Support/LEB128.h"
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <xar/xar.h>
|
#include <xar/xar.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1036,7 +1036,7 @@ private:
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
void BitcodeBundleSection::finalize() {
|
void BitcodeBundleSection::finalize() {
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
using namespace llvm::sys::fs;
|
using namespace llvm::sys::fs;
|
||||||
CHECK_EC(createTemporaryFile("bitcode-bundle", "xar", xarPath));
|
CHECK_EC(createTemporaryFile("bitcode-bundle", "xar", xarPath));
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ void BitcodeBundleSection::finalize() {
|
||||||
CHECK_EC(xar_close(xar));
|
CHECK_EC(xar_close(xar));
|
||||||
|
|
||||||
file_size(xarPath, xarSize);
|
file_size(xarPath, xarSize);
|
||||||
#endif // defined(HAVE_LIBXAR)
|
#endif // defined(LLVM_HAVE_LIBXAR)
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcodeBundleSection::writeTo(uint8_t *buf) const {
|
void BitcodeBundleSection::writeTo(uint8_t *buf) const {
|
||||||
|
|
|
@ -11,7 +11,7 @@ llvm_canonicalize_cmake_booleans(
|
||||||
LLVM_ENABLE_ZLIB
|
LLVM_ENABLE_ZLIB
|
||||||
LLVM_ENABLE_LIBXML2
|
LLVM_ENABLE_LIBXML2
|
||||||
LLD_DEFAULT_LD_LLD_IS_MINGW
|
LLD_DEFAULT_LD_LLD_IS_MINGW
|
||||||
HAVE_LIBXAR
|
LLVM_HAVE_LIBXAR
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_lit_site_cfg(
|
configure_lit_site_cfg(
|
||||||
|
|
|
@ -15,7 +15,7 @@ config.lld_tools_dir = "@LLD_TOOLS_DIR@"
|
||||||
config.target_triple = "@TARGET_TRIPLE@"
|
config.target_triple = "@TARGET_TRIPLE@"
|
||||||
config.python_executable = "@Python3_EXECUTABLE@"
|
config.python_executable = "@Python3_EXECUTABLE@"
|
||||||
config.have_zlib = @LLVM_ENABLE_ZLIB@
|
config.have_zlib = @LLVM_ENABLE_ZLIB@
|
||||||
config.have_libxar = @HAVE_LIBXAR@
|
config.have_libxar = @LLVM_HAVE_LIBXAR@
|
||||||
config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
|
config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
|
||||||
config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@
|
config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@
|
||||||
config.ld_lld_default_mingw = @LLD_DEFAULT_LD_LLD_IS_MINGW@
|
config.ld_lld_default_mingw = @LLD_DEFAULT_LD_LLD_IS_MINGW@
|
||||||
|
|
|
@ -20,7 +20,7 @@ target_link_libraries(lld
|
||||||
lldWasm
|
lldWasm
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_LIBXAR)
|
if(LLVM_HAVE_LIBXAR)
|
||||||
target_link_libraries(lld PRIVATE ${XAR_LIB})
|
target_link_libraries(lld PRIVATE ${XAR_LIB})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -189,8 +189,8 @@ else()
|
||||||
set(LLVM_ENABLE_TERMINFO 0)
|
set(LLVM_ENABLE_TERMINFO 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_library_exists(xar xar_open "" HAVE_LIBXAR)
|
check_library_exists(xar xar_open "" LLVM_HAVE_LIBXAR)
|
||||||
if(HAVE_LIBXAR)
|
if(LLVM_HAVE_LIBXAR)
|
||||||
set(XAR_LIB xar)
|
set(XAR_LIB xar)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,8 @@ set(LLVM_ENABLE_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||||
set(LLVM_DEFAULT_EXTERNAL_LIT "@LLVM_CONFIG_DEFAULT_EXTERNAL_LIT@")
|
set(LLVM_DEFAULT_EXTERNAL_LIT "@LLVM_CONFIG_DEFAULT_EXTERNAL_LIT@")
|
||||||
set(LLVM_LIT_ARGS "@LLVM_LIT_ARGS@")
|
set(LLVM_LIT_ARGS "@LLVM_LIT_ARGS@")
|
||||||
|
|
||||||
|
set(LLVM_HAVE_LIBXAR "@LLVM_HAVE_LIBXAR@")
|
||||||
|
|
||||||
if(NOT TARGET LLVMSupport)
|
if(NOT TARGET LLVMSupport)
|
||||||
@LLVM_CONFIG_INCLUDE_EXPORTS@
|
@LLVM_CONFIG_INCLUDE_EXPORTS@
|
||||||
@llvm_config_include_buildtree_only_exports@
|
@llvm_config_include_buildtree_only_exports@
|
||||||
|
|
|
@ -220,9 +220,6 @@
|
||||||
/* Define if the setupterm() function is supported this platform. */
|
/* Define if the setupterm() function is supported this platform. */
|
||||||
#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
|
#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
|
||||||
|
|
||||||
/* Define if the xar_open() function is supported this platform. */
|
|
||||||
#cmakedefine HAVE_LIBXAR ${HAVE_LIBXAR}
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <termios.h> header file. */
|
/* Define to 1 if you have the <termios.h> header file. */
|
||||||
#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
|
#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
|
||||||
|
|
||||||
|
|
|
@ -94,4 +94,7 @@
|
||||||
/* Define to 1 to enable the experimental new pass manager by default */
|
/* Define to 1 to enable the experimental new pass manager by default */
|
||||||
#cmakedefine01 LLVM_ENABLE_NEW_PASS_MANAGER
|
#cmakedefine01 LLVM_ENABLE_NEW_PASS_MANAGER
|
||||||
|
|
||||||
|
/* Define if the xar_open() function is supported on this platform. */
|
||||||
|
#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
llvm_canonicalize_cmake_booleans(
|
llvm_canonicalize_cmake_booleans(
|
||||||
BUILD_SHARED_LIBS
|
BUILD_SHARED_LIBS
|
||||||
HAVE_LIBXAR
|
LLVM_HAVE_LIBXAR
|
||||||
HAVE_OCAMLOPT
|
HAVE_OCAMLOPT
|
||||||
HAVE_OCAML_OUNIT
|
HAVE_OCAML_OUNIT
|
||||||
LLVM_ENABLE_DIA_SDK
|
LLVM_ENABLE_DIA_SDK
|
||||||
|
|
|
@ -36,7 +36,7 @@ config.host_ldflags = '@HOST_LDFLAGS@'
|
||||||
config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
|
config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
|
||||||
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
|
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
|
||||||
config.have_zlib = @LLVM_ENABLE_ZLIB@
|
config.have_zlib = @LLVM_ENABLE_ZLIB@
|
||||||
config.have_libxar = @HAVE_LIBXAR@
|
config.have_libxar = @LLVM_HAVE_LIBXAR@
|
||||||
config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
|
config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
|
||||||
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
|
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
|
||||||
config.enable_ffi = @LLVM_ENABLE_FFI@
|
config.enable_ffi = @LLVM_ENABLE_FFI@
|
||||||
|
|
|
@ -35,7 +35,7 @@ add_llvm_tool(llvm-objdump
|
||||||
OtoolOptsTableGen
|
OtoolOptsTableGen
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_LIBXAR)
|
if(LLVM_HAVE_LIBXAR)
|
||||||
target_link_libraries(llvm-objdump PRIVATE ${XAR_LIB})
|
target_link_libraries(llvm-objdump PRIVATE ${XAR_LIB})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <xar/xar.h>
|
#include <xar/xar.h>
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ typedef std::pair<uint64_t, DiceRef> DiceTableEntry;
|
||||||
typedef std::vector<DiceTableEntry> DiceTable;
|
typedef std::vector<DiceTableEntry> DiceTable;
|
||||||
typedef DiceTable::iterator dice_table_iterator;
|
typedef DiceTable::iterator dice_table_iterator;
|
||||||
|
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
namespace {
|
namespace {
|
||||||
struct ScopedXarFile {
|
struct ScopedXarFile {
|
||||||
xar_t xar;
|
xar_t xar;
|
||||||
|
@ -211,7 +211,7 @@ struct ScopedXarIter {
|
||||||
operator xar_iter_t() { return iter; }
|
operator xar_iter_t() { return iter; }
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
#endif // defined(HAVE_LIBXAR)
|
#endif // defined(LLVM_HAVE_LIBXAR)
|
||||||
|
|
||||||
// This is used to search for a data in code table entry for the PC being
|
// This is used to search for a data in code table entry for the PC being
|
||||||
// disassembled. The j parameter has the PC in j.first. A single data in code
|
// disassembled. The j parameter has the PC in j.first. A single data in code
|
||||||
|
@ -1697,12 +1697,12 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||||
StringRef DisSegName, StringRef DisSectName);
|
StringRef DisSegName, StringRef DisSectName);
|
||||||
static void DumpProtocolSection(MachOObjectFile *O, const char *sect,
|
static void DumpProtocolSection(MachOObjectFile *O, const char *sect,
|
||||||
uint32_t size, uint32_t addr);
|
uint32_t size, uint32_t addr);
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
static void DumpBitcodeSection(MachOObjectFile *O, const char *sect,
|
static void DumpBitcodeSection(MachOObjectFile *O, const char *sect,
|
||||||
uint32_t size, bool verbose,
|
uint32_t size, bool verbose,
|
||||||
bool PrintXarHeader, bool PrintXarFileHeaders,
|
bool PrintXarHeader, bool PrintXarFileHeaders,
|
||||||
std::string XarMemberName);
|
std::string XarMemberName);
|
||||||
#endif // defined(HAVE_LIBXAR)
|
#endif // defined(LLVM_HAVE_LIBXAR)
|
||||||
|
|
||||||
static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
|
static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
|
||||||
bool verbose) {
|
bool verbose) {
|
||||||
|
@ -1773,13 +1773,13 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
|
||||||
DumpProtocolSection(O, sect, sect_size, sect_addr);
|
DumpProtocolSection(O, sect, sect_size, sect_addr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
if (SegName == "__LLVM" && SectName == "__bundle") {
|
if (SegName == "__LLVM" && SectName == "__bundle") {
|
||||||
DumpBitcodeSection(O, sect, sect_size, verbose, SymbolicOperands,
|
DumpBitcodeSection(O, sect, sect_size, verbose, SymbolicOperands,
|
||||||
ArchiveHeaders, "");
|
ArchiveHeaders, "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif // defined(HAVE_LIBXAR)
|
#endif // defined(LLVM_HAVE_LIBXAR)
|
||||||
switch (section_type) {
|
switch (section_type) {
|
||||||
case MachO::S_REGULAR:
|
case MachO::S_REGULAR:
|
||||||
DumpRawSectionContents(O, sect, sect_size, sect_addr);
|
DumpRawSectionContents(O, sect, sect_size, sect_addr);
|
||||||
|
@ -6460,7 +6460,7 @@ static void DumpProtocolSection(MachOObjectFile *O, const char *sect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBXAR
|
#ifdef LLVM_HAVE_LIBXAR
|
||||||
static inline void swapStruct(struct xar_header &xar) {
|
static inline void swapStruct(struct xar_header &xar) {
|
||||||
sys::swapByteOrder(xar.magic);
|
sys::swapByteOrder(xar.magic);
|
||||||
sys::swapByteOrder(xar.size);
|
sys::swapByteOrder(xar.size);
|
||||||
|
@ -6823,7 +6823,7 @@ static void DumpBitcodeSection(MachOObjectFile *O, const char *sect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // defined(HAVE_LIBXAR)
|
#endif // defined(LLVM_HAVE_LIBXAR)
|
||||||
|
|
||||||
static void printObjcMetaData(MachOObjectFile *O, bool verbose) {
|
static void printObjcMetaData(MachOObjectFile *O, bool verbose) {
|
||||||
if (O->is64Bit())
|
if (O->is64Bit())
|
||||||
|
|
|
@ -53,9 +53,9 @@ write_lit_cfg("lit_site_cfg") {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxar) {
|
if (llvm_enable_libxar) {
|
||||||
extra_values += [ "HAVE_LIBXAR=1" ]
|
extra_values += [ "LLVM_HAVE_LIBXAR=1" ]
|
||||||
} else {
|
} else {
|
||||||
extra_values += [ "HAVE_LIBXAR=0" ] # Must be 0.
|
extra_values += [ "LLVM_HAVE_LIBXAR=0" ] # Must be 0.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxml2) {
|
if (llvm_enable_libxml2) {
|
||||||
|
|
|
@ -296,12 +296,6 @@ write_cmake_config("config") {
|
||||||
values += [ "HAVE_LIBEDIT=" ]
|
values += [ "HAVE_LIBEDIT=" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxar) {
|
|
||||||
values += [ "HAVE_LIBXAR=1" ]
|
|
||||||
} else {
|
|
||||||
values += [ "HAVE_LIBXAR=" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (llvm_enable_terminfo) {
|
if (llvm_enable_terminfo) {
|
||||||
values += [ "LLVM_ENABLE_TERMINFO=1" ]
|
values += [ "LLVM_ENABLE_TERMINFO=1" ]
|
||||||
} else {
|
} else {
|
||||||
|
@ -368,6 +362,12 @@ write_cmake_config("llvm-config") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (llvm_enable_libxar) {
|
||||||
|
values += [ "LLVM_HAVE_LIBXAR=1" ]
|
||||||
|
} else {
|
||||||
|
values += [ "LLVM_HAVE_LIBXAR=" ]
|
||||||
|
}
|
||||||
|
|
||||||
if (llvm_enable_threads) {
|
if (llvm_enable_threads) {
|
||||||
values += [ "LLVM_ENABLE_THREADS=1" ]
|
values += [ "LLVM_ENABLE_THREADS=1" ]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -162,9 +162,9 @@ write_lit_config("lit_site_cfg") {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_libxar) {
|
if (llvm_enable_libxar) {
|
||||||
extra_values += [ "HAVE_LIBXAR=1" ]
|
extra_values += [ "LLVM_HAVE_LIBXAR=1" ]
|
||||||
} else {
|
} else {
|
||||||
extra_values += [ "HAVE_LIBXAR=0" ] # Must be 0.
|
extra_values += [ "LLVM_HAVE_LIBXAR=0" ] # Must be 0.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_enable_dia_sdk) {
|
if (llvm_enable_dia_sdk) {
|
||||||
|
|
Loading…
Reference in New Issue