From b6ed7cd424609291b39622ca15a8e5b3fef46599 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 15 Mar 2016 05:31:09 +0000 Subject: clang: Fix build on musl Move -L flags to LDFLAGS, avoid compiler warnings Signed-off-by: Khem Raj --- ...pen64-fseeko64-ftello64-tmpfile64-on-musl.patch | 96 ++++++++++++++++++++++ .../clang/0002-Do-not-assume-linux-glibc.patch | 28 +++++++ recipes-devtools/clang/clang_git.bb | 6 +- 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 recipes-devtools/clang/clang/0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch create mode 100644 recipes-devtools/clang/clang/0002-Do-not-assume-linux-glibc.patch diff --git a/recipes-devtools/clang/clang/0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch b/recipes-devtools/clang/clang/0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch new file mode 100644 index 0000000..76ee9a2 --- /dev/null +++ b/recipes-devtools/clang/clang/0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch @@ -0,0 +1,96 @@ +From 01501b1e05e60ab5446fa12a15071049f07e3ae0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 15 Mar 2016 05:25:36 +0000 +Subject: [PATCH 1/2] remove fopen64/fseeko64/ftello64/tmpfile64 on musl + +They are not available + +Signed-off-by: Khem Raj +--- + include/llvm/Analysis/TargetLibraryInfo.def | 12 ------------ + lib/Transforms/IPO/InferFunctionAttrs.cpp | 25 ------------------------- + 2 files changed, 37 deletions(-) + +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def +index 7798e3c..65158b8 100644 +--- a/include/llvm/Analysis/TargetLibraryInfo.def ++++ b/include/llvm/Analysis/TargetLibraryInfo.def +@@ -525,9 +525,6 @@ TLI_DEFINE_STRING_INTERNAL("fmodl") + /// FILE *fopen(const char *filename, const char *mode); + TLI_DEFINE_ENUM_INTERNAL(fopen) + TLI_DEFINE_STRING_INTERNAL("fopen") +-/// FILE *fopen64(const char *filename, const char *opentype) +-TLI_DEFINE_ENUM_INTERNAL(fopen64) +-TLI_DEFINE_STRING_INTERNAL("fopen64") + /// int fprintf(FILE *stream, const char *format, ...); + TLI_DEFINE_ENUM_INTERNAL(fprintf) + TLI_DEFINE_STRING_INTERNAL("fprintf") +@@ -561,9 +558,6 @@ TLI_DEFINE_STRING_INTERNAL("fseek") + /// int fseeko(FILE *stream, off_t offset, int whence); + TLI_DEFINE_ENUM_INTERNAL(fseeko) + TLI_DEFINE_STRING_INTERNAL("fseeko") +-/// int fseeko64(FILE *stream, off64_t offset, int whence) +-TLI_DEFINE_ENUM_INTERNAL(fseeko64) +-TLI_DEFINE_STRING_INTERNAL("fseeko64") + /// int fsetpos(FILE *stream, const fpos_t *pos); + TLI_DEFINE_ENUM_INTERNAL(fsetpos) + TLI_DEFINE_STRING_INTERNAL("fsetpos") +@@ -585,9 +579,6 @@ TLI_DEFINE_STRING_INTERNAL("ftell") + /// off_t ftello(FILE *stream); + TLI_DEFINE_ENUM_INTERNAL(ftello) + TLI_DEFINE_STRING_INTERNAL("ftello") +-/// off64_t ftello64(FILE *stream) +-TLI_DEFINE_ENUM_INTERNAL(ftello64) +-TLI_DEFINE_STRING_INTERNAL("ftello64") + /// int ftrylockfile(FILE *file); + TLI_DEFINE_ENUM_INTERNAL(ftrylockfile) + TLI_DEFINE_STRING_INTERNAL("ftrylockfile") +@@ -1050,9 +1041,6 @@ TLI_DEFINE_STRING_INTERNAL("times") + /// FILE *tmpfile(void); + TLI_DEFINE_ENUM_INTERNAL(tmpfile) + TLI_DEFINE_STRING_INTERNAL("tmpfile") +-/// FILE *tmpfile64(void) +-TLI_DEFINE_ENUM_INTERNAL(tmpfile64) +-TLI_DEFINE_STRING_INTERNAL("tmpfile64") + /// int toascii(int c); + TLI_DEFINE_ENUM_INTERNAL(toascii) + TLI_DEFINE_STRING_INTERNAL("toascii") +diff --git a/lib/Transforms/IPO/InferFunctionAttrs.cpp b/lib/Transforms/IPO/InferFunctionAttrs.cpp +index 4295a75..f6d19eb 100644 +--- a/lib/Transforms/IPO/InferFunctionAttrs.cpp ++++ b/lib/Transforms/IPO/InferFunctionAttrs.cpp +@@ -844,31 +844,6 @@ static bool inferPrototypeAttributes(Function &F, + Changed |= setOnlyReadsMemory(F, 1); + Changed |= setOnlyReadsMemory(F, 2); + return Changed; +- case LibFunc::fopen64: +- if (FTy->getNumParams() != 2 || !FTy->getReturnType()->isPointerTy() || +- !FTy->getParamType(0)->isPointerTy() || +- !FTy->getParamType(1)->isPointerTy()) +- return false; +- Changed |= setDoesNotThrow(F); +- Changed |= setDoesNotAlias(F, 0); +- Changed |= setDoesNotCapture(F, 1); +- Changed |= setDoesNotCapture(F, 2); +- Changed |= setOnlyReadsMemory(F, 1); +- Changed |= setOnlyReadsMemory(F, 2); +- return Changed; +- case LibFunc::fseeko64: +- case LibFunc::ftello64: +- if (FTy->getNumParams() == 0 || !FTy->getParamType(0)->isPointerTy()) +- return false; +- Changed |= setDoesNotThrow(F); +- Changed |= setDoesNotCapture(F, 1); +- return Changed; +- case LibFunc::tmpfile64: +- if (!FTy->getReturnType()->isPointerTy()) +- return false; +- Changed |= setDoesNotThrow(F); +- Changed |= setDoesNotAlias(F, 0); +- return Changed; + case LibFunc::fstat64: + case LibFunc::fstatvfs64: + if (FTy->getNumParams() != 2 || !FTy->getParamType(1)->isPointerTy()) +-- +1.9.1 + diff --git a/recipes-devtools/clang/clang/0002-Do-not-assume-linux-glibc.patch b/recipes-devtools/clang/clang/0002-Do-not-assume-linux-glibc.patch new file mode 100644 index 0000000..d194898 --- /dev/null +++ b/recipes-devtools/clang/clang/0002-Do-not-assume-linux-glibc.patch @@ -0,0 +1,28 @@ +From 9f7b677d3a6582b232e16cb5518935633b2e65fb Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 15 Mar 2016 05:26:47 +0000 +Subject: [PATCH 2/2] Do not assume linux == glibc + +musl's implementation of std functions is different + +Signed-off-by: Khem Raj +--- + lib/Support/DynamicLibrary.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp +index 9a7aeb5..e3b7fe2 100644 +--- a/lib/Support/DynamicLibrary.cpp ++++ b/lib/Support/DynamicLibrary.cpp +@@ -143,7 +143,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { + // On linux we have a weird situation. The stderr/out/in symbols are both + // macros and global variables because of standards requirements. So, we + // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. +-#if defined(__linux__) and !defined(__ANDROID__) ++#if defined(__linux__) and defined(__GLIBC__) + { + EXPLICIT_SYMBOL(stderr); + EXPLICIT_SYMBOL(stdout); +-- +1.9.1 + diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index bbc6f7b..698c7b4 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb @@ -16,8 +16,11 @@ LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=4c0bc17c954e99fd547528d938832bfa; \ SRC_URI = "${LLVM_GIT}/llvm.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};name=llvm \ ${LLVM_GIT}/clang.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};destsuffix=git/tools/clang;name=clang \ file://0001-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-compile.patch \ + file://0002-Do-not-assume-linux-glibc.patch \ " +SRC_URI_append_libc-musl_class-target = " file://0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch " + SRCREV_FORMAT = "llvm_clang" INHIBIT_DEFAULT_DEPS = "1" @@ -45,7 +48,8 @@ def get_clang_target_arch(bb, d): #TUNE_CCARGS_remove = "-mthumb-interwork" #TUNE_CCARGS_remove = "-march=armv7-a" #TUNE_CCARGS_remove = "-marm" -TUNE_CCARGS_append_class-target = " -D__extern_always_inline=inline -L${PKG_CONFIG_SYSROOT_DIR}${libdir}/libxml2 -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/libxml2 " +TUNE_CCARGS_append_class-target = " -D__extern_always_inline=inline -I${PKG_CONFIG_SYSROOT_DIR}${includedir}/libxml2 " +LDFLAGS_append_class-target = " -L${PKG_CONFIG_SYSROOT_DIR}${libdir}/libxml2 " EXTRA_OECMAKE="-DLLVM_ENABLE_RTTI:BOOL=True \ -DLLVM_ENABLE_FFI:BOOL=False \ -- cgit v1.2.3-54-g00ecf