diff options
author | Khem Raj <raj.khem@gmail.com> | 2022-12-09 16:33:47 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2022-12-11 16:22:58 -0800 |
commit | 3b030869732a751a7e67c37cb477658fd4d9cc1d (patch) | |
tree | 2586c7d95dba0bce146a4f596d0eddf3052c3c1e /recipes-devtools | |
parent | fc9c05a33061d4185d17be90c6604e817b51f3ac (diff) | |
download | meta-clang-3b030869732a751a7e67c37cb477658fd4d9cc1d.tar.gz |
clang: Fix build with LFS64 on musl
Ensures that correct cmake checks are used to enable LFS64
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'recipes-devtools')
-rw-r--r-- | recipes-devtools/clang/clang/0035-cmake-Enable-64bit-off_t-on-32bit-glibc-systems.patch | 84 | ||||
-rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 85 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0035-cmake-Enable-64bit-off_t-on-32bit-glibc-systems.patch b/recipes-devtools/clang/clang/0035-cmake-Enable-64bit-off_t-on-32bit-glibc-systems.patch new file mode 100644 index 0000000..77bad54 --- /dev/null +++ b/recipes-devtools/clang/clang/0035-cmake-Enable-64bit-off_t-on-32bit-glibc-systems.patch | |||
@@ -0,0 +1,84 @@ | |||
1 | From e5edc21a119c9bc0bea6e942adf8b172ec8a987a Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 9 Dec 2022 16:17:12 -0800 | ||
4 | Subject: [PATCH] cmake: Enable 64bit off_t on 32bit glibc systems | ||
5 | |||
6 | Pass -D_FILE_OFFSET_BITS=64 to compiler flags on 32bit glibc based | ||
7 | systems. This will make sure that 64bit versions of LFS functions are | ||
8 | used e.g. seek will behave same as lseek64. Also revert [1] partially | ||
9 | because this added a cmake test to detect lseek64 but then forgot to | ||
10 | pass the needed macro to actual compile, this test was incomplete too | ||
11 | since libc implementations like musl has 64bit off_t by default on 32bit | ||
12 | systems and does not bundle[2] -D_LARGEFILE64_SOURCE under -D_GNU_SOURCE | ||
13 | like glibc, which means the compile now fails on musl because the cmake | ||
14 | check passes but we do not have _LARGEFILE64_SOURCE defined. Using the | ||
15 | *64 function was transitional anyways so use -D_FILE_OFFSET_BITS=64 | ||
16 | instead | ||
17 | |||
18 | [1] https://github.com/llvm/llvm-project/commit/8db7e5e4eed4c4e697dc3164f2c9351d8c3e942b | ||
19 | [2] https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc | ||
20 | |||
21 | Upstream-Status: Submitted [https://reviews.llvm.org/D139752] | ||
22 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
23 | --- | ||
24 | llvm/cmake/config-ix.cmake | 8 +++++--- | ||
25 | llvm/include/llvm/Config/config.h.cmake | 3 --- | ||
26 | llvm/lib/Support/raw_ostream.cpp | 2 -- | ||
27 | 3 files changed, 5 insertions(+), 8 deletions(-) | ||
28 | |||
29 | diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake | ||
30 | index 7e657fd1532d..b03d433ea5b0 100644 | ||
31 | --- a/llvm/cmake/config-ix.cmake | ||
32 | +++ b/llvm/cmake/config-ix.cmake | ||
33 | @@ -284,9 +284,6 @@ check_symbol_exists(futimes sys/time.h HAVE_FUTIMES) | ||
34 | if( HAVE_SIGNAL_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*" AND NOT APPLE ) | ||
35 | check_symbol_exists(sigaltstack signal.h HAVE_SIGALTSTACK) | ||
36 | endif() | ||
37 | -set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE") | ||
38 | -check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64) | ||
39 | -set(CMAKE_REQUIRED_DEFINITIONS "") | ||
40 | check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL) | ||
41 | check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO) | ||
42 | check_symbol_exists(mallinfo2 malloc.h HAVE_MALLINFO2) | ||
43 | @@ -350,6 +347,11 @@ check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC) | ||
44 | if( LLVM_USING_GLIBC ) | ||
45 | add_definitions( -D_GNU_SOURCE ) | ||
46 | list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") | ||
47 | +# enable 64bit off_t on 32bit systems using glibc | ||
48 | + if (CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
49 | + add_definitions( -D_FILE_OFFSET_BITS=64 ) | ||
50 | + list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64") | ||
51 | + endif() | ||
52 | endif() | ||
53 | # This check requires _GNU_SOURCE | ||
54 | if (NOT PURE_WINDOWS) | ||
55 | diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake | ||
56 | index 21ce3a94a5ed..d551ebad5c0c 100644 | ||
57 | --- a/llvm/include/llvm/Config/config.h.cmake | ||
58 | +++ b/llvm/include/llvm/Config/config.h.cmake | ||
59 | @@ -128,9 +128,6 @@ | ||
60 | /* Define to 1 if you have the <link.h> header file. */ | ||
61 | #cmakedefine HAVE_LINK_H ${HAVE_LINK_H} | ||
62 | |||
63 | -/* Define to 1 if you have the `lseek64' function. */ | ||
64 | -#cmakedefine HAVE_LSEEK64 ${HAVE_LSEEK64} | ||
65 | - | ||
66 | /* Define to 1 if you have the <mach/mach.h> header file. */ | ||
67 | #cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H} | ||
68 | |||
69 | diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp | ||
70 | index 651949ad5765..0bc71812cbd4 100644 | ||
71 | --- a/llvm/lib/Support/raw_ostream.cpp | ||
72 | +++ b/llvm/lib/Support/raw_ostream.cpp | ||
73 | @@ -804,8 +804,6 @@ uint64_t raw_fd_ostream::seek(uint64_t off) { | ||
74 | flush(); | ||
75 | #ifdef _WIN32 | ||
76 | pos = ::_lseeki64(FD, off, SEEK_SET); | ||
77 | -#elif defined(HAVE_LSEEK64) | ||
78 | - pos = ::lseek64(FD, off, SEEK_SET); | ||
79 | #else | ||
80 | pos = ::lseek(FD, off, SEEK_SET); | ||
81 | #endif | ||
82 | -- | ||
83 | 2.38.1 | ||
84 | |||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index a0f8a00..db5463c 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
@@ -44,6 +44,7 @@ SRC_URI = "\ | |||
44 | file://0032-compiler-rt-Enable-__int128-for-ppc32.patch \ | 44 | file://0032-compiler-rt-Enable-__int128-for-ppc32.patch \ |
45 | file://0033-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch \ | 45 | file://0033-llvm-Do-not-use-cmake-infra-to-detect-libzstd.patch \ |
46 | file://0034-Revert-MIPS-compiler-rt-Fix-stat-struct-s-size-for-O.patch \ | 46 | file://0034-Revert-MIPS-compiler-rt-Fix-stat-struct-s-size-for-O.patch \ |
47 | file://0035-cmake-Enable-64bit-off_t-on-32bit-glibc-systems.patch \ | ||
47 | " | 48 | " |
48 | # Fallback to no-PIE if not set | 49 | # Fallback to no-PIE if not set |
49 | GCCPIE ??= "" | 50 | GCCPIE ??= "" |