Skip to content

Commit 3669bf9

Browse files
committed
Build fixes for LLVM 19
1 parent 8055bd9 commit 3669bf9

File tree

6 files changed

+67
-78
lines changed

6 files changed

+67
-78
lines changed

clang/tools/libclang/CIndexer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "clang/Basic/Version.h"
1717
#include "clang/Config/config.h"
1818
#include "clang/Driver/Driver.h"
19-
#include "clang/Config/config.h"
2019
#include "llvm/ADT/STLExtras.h"
2120
#include "llvm/ADT/SmallString.h"
2221
#include "llvm/Support/FileSystem.h"

lld/COFF/DLL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ void IdataContents::create(COFFLinkerContext &ctx) {
705705

706706
// Remap the dll name
707707
auto dllName = syms[0]->getDLLName();
708-
auto dllMapping = config->dllImportRename.find(dllName);
709-
if (dllMapping != config->dllImportRename.end())
708+
auto dllMapping = ctx.config.dllImportRename.find(dllName);
709+
if (dllMapping != ctx.config.dllImportRename.end())
710710
dllName = dllMapping->second;
711711

712712
// Create the import table header.
@@ -751,8 +751,8 @@ void DelayLoadContents::create(Defined *h) {
751751

752752
// Remap the dll name
753753
auto dllName = syms[0]->getDLLName();
754-
auto dllMapping = config->dllImportRename.find(dllName);
755-
if (dllMapping != config->dllImportRename.end())
754+
auto dllMapping = ctx.config.dllImportRename.find(dllName);
755+
if (dllMapping != ctx.config.dllImportRename.end())
756756
dllName = dllMapping->second;
757757

758758
// Create the delay import table header.

lld/MinGW/Driver.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ static void printHelp(const char *argv0) {
103103
false /*ShowHidden*/, true /*ShowAllAliases*/);
104104
lld::outs() << "\n";
105105
}
106-
namespace lld {
107-
namespace coff {
108-
void printHelp(const char *argv0);
109-
} // namespace coff
110-
} // namespace lld
111106

112107
static cl::TokenizerCallback getQuotingStyle() {
113108
if (Triple(sys::getProcessTriple()).getOS() == Triple::Win32)
@@ -195,8 +190,6 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
195190

196191
if (args.hasArg(OPT_help)) {
197192
printHelp(argsArr[0]);
198-
// Also print lld-link help
199-
coff::printHelp(argsArr[0]);
200193
return true;
201194
}
202195

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,6 @@ void request_evaluate(const llvm::json::Object &request) {
13601360
if (frame.IsValid()) {
13611361
g_dap.focus_tid = frame.GetThread().GetThreadID();
13621362
}
1363-
if (!expression.empty() && (expression[0] == '`' || expression[0] == '/')) {
13641363
auto result =
13651364
RunLLDBCommandsVerbatim(llvm::StringRef(), {std::string(expression)});
13661365
EmplaceSafeString(body, "result", result);

nidefawl/build-linux-x86_64.dockerfile

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,55 @@ RUN apt-get update -yqq
66
RUN apt-get install -qqy --no-install-recommends sudo wget gnupg2 ca-certificates
77
# add user builder
88
RUN useradd -ms /bin/bash builder
9+
WORKDIR /home/builder
10+
911
# add user builder to sudoers
1012
RUN echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
11-
# switch to user builder
12-
USER builder
13-
ENV PATH=/opt/cmake/bin:$PATH:/home/builder/.local/bin
14-
WORKDIR /home/builder
1513

16-
RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
17-
RUN cat /etc/apt/trusted.gpg.d/apt.llvm.org.asc
18-
RUN sudo bash -c "echo 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' >> /etc/apt/sources.list"
19-
RUN cat /etc/apt/sources.list
20-
RUN sudo apt-get update -yqq
21-
RUN apt search clang
22-
RUN sudo apt-get install -qqy --no-install-recommends \
14+
RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
15+
RUN bash -c "echo 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' >> /etc/apt/sources.list"
16+
RUN apt-get update -yqq
17+
RUN apt-get install -qqy --no-install-recommends \
2318
autoconf-archive autopoint build-essential automake bzip2 clang-18 python3 \
2419
clang-tidy-18 curl e2fslibs-dev file gettext git gnupg2 less libasound2-dev \
2520
libatomic1 libattr1-dev libbsd-dev libbsd0 libc++-18-dev libc++abi-18-dev \
2621
libedit-dev libgtk-3-dev liblzma-dev libncurses-dev libncursesw6 libssl-dev \
2722
libtinfo6 libtool libunwind-18-dev libx11-dev libxcursor-dev libxi-dev nano \
2823
libxinerama-dev libxml2 libxrandr-dev libltdl-dev lld-18 nsis pkg-config \
2924
python3-dev python3-distutils python3-pip swig unzip unzip yasm wget zip \
30-
rsync
31-
32-
RUN pip3 install pygments pyyaml
25+
rsync libclang-rt-18-dev
3326

34-
# enfore lld-18 as linker
35-
RUN sudo ln -s /usr/bin/lld-18 /usr/local/bin/ld
27+
# enfore lld-18 as linker
28+
RUN ln -s /usr/bin/lld-18 /usr/local/bin/ld
3629

3730
RUN wget -nv https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-linux.zip
38-
RUN sudo unzip ninja-linux.zip -d /usr/local/bin/ && rm ninja-linux.zip
31+
RUN unzip ninja-linux.zip -d /usr/local/bin/ && rm ninja-linux.zip
3932

4033
# Manually install a newer version of CMake; this is needed since building
4134
# LLVM requires CMake 3.13.4, while Ubuntu 18.04 ships with 3.10.2. If
4235
# updating to a newer distribution, this can be dropped.
4336
RUN wget -nv https://github.com/Kitware/CMake/releases/download/v3.29.3/cmake-3.29.3-linux-$(uname -m).tar.gz
4437
RUN tar -zxf cmake-*.tar.gz && rm cmake-*.tar.gz
45-
RUN sudo mv cmake-* /opt/cmake && sudo chown -R root:root /opt/cmake
38+
RUN mv cmake-* /opt/cmake && chown -R root:root /opt/cmake
39+
40+
ENV PATH=/opt/cmake/bin:$PATH:/home/builder/.local/bin
4641

4742

48-
RUN sudo git config --global user.name "LLVM MinGW" && \
49-
sudo git config --global user.email root@localhost && \
50-
sudo git config --global init.defaultBranch main && \
51-
sudo git config --global advice.detachedHead false
43+
RUN git config --global user.name "LLVM MinGW" && \
44+
git config --global user.email root@localhost && \
45+
git config --global init.defaultBranch main && \
46+
git config --global advice.detachedHead false
5247

53-
RUN sudo mkdir -p /build && sudo chown -R builder:builder /build && \
54-
mkdir -p /build/llvm
48+
RUN mkdir -p /build && chown -R builder:builder /build
5549

50+
# switch to user builder
51+
USER builder
52+
RUN mkdir -p /build/llvm
5653
WORKDIR /build/llvm
54+
55+
RUN pip3 install pygments pyyaml
56+
57+
5758
ARG GIT_REPO=https://github.com/nidefawl/llvm-project.git
5859
ARG GIT_BRANCH=llvm-dev
5960
RUN git clone --depth=1 --branch=$GIT_BRANCH --single-branch $GIT_REPO llvm-project
@@ -64,16 +65,3 @@ RUN ./build-linux-x86_64.sh
6465

6566
ENV LD_LIBRARY_PATH=/build/llvm/llvm-linux-x86_64/lib/x86_64-unknown-linux-gnu
6667
ENV PATH=/build/llvm/llvm-linux-x86_64/bin:$PATH
67-
68-
# steal the local runtimes and provide them for packaging, what is the worst that could happen?
69-
# in theory this should work
70-
RUN cp /lib/x86_64-linux-gnu/libc++abi.so.1 /build/llvm/llvm-linux-x86_64/lib && \
71-
cp /lib/x86_64-linux-gnu/libc++.so.1 /build/llvm/llvm-linux-x86_64/lib && \
72-
cp /lib/x86_64-linux-gnu/libunwind.so.1 /build/llvm/llvm-linux-x86_64/lib
73-
74-
RUN cp /lib/x86_64-linux-gnu/libncurses.so.6 /build/llvm/llvm-linux-x86_64/lib && \
75-
cp /lib/x86_64-linux-gnu/libform.so.6 /build/llvm/llvm-linux-x86_64/lib && \
76-
cp /lib/x86_64-linux-gnu/libtinfo.so.6 /build/llvm/llvm-linux-x86_64/lib && \
77-
cp /lib/x86_64-linux-gnu/libpanel.so.6 /build/llvm/llvm-linux-x86_64/lib
78-
79-
RUN tar -cjSf toolchain.bz2 --transform "s%^llvm-linux-x86_64%llvm-clang-ubuntu-22.04-x86_64%" llvm-linux-x86_64

nidefawl/build-linux-x86_64.sh

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ if [ ! -z "$BOOT_TC" ]; then
2626
export PATH=$BOOT_TC/bin:$PATH
2727
export LD_LIBRARY_PATH=$BOOT_TC/lib/x86_64-unknown-linux-gnu
2828
else
29-
export CC="clang-16"
30-
export CXX="clang++-16"
29+
export CC="clang-18"
30+
export CXX="clang++-18"
3131
# use lld if found
3232
/usr/bin/which "ld.lld" &> /dev/null && {
33-
EXTRA_ARGS+="-DLLVM_USE_LINKER=lld-16 "
33+
EXTRA_ARGS+="-DLLVM_USE_LINKER=lld-18 "
3434
EXTRA_ARGS+="-DLLVM_ENABLE_LTO=thin "
3535
}
3636
fi
@@ -59,9 +59,9 @@ printf "#include <cstddef>\nint main(){return sizeof(size_t);}" \
5959
exit 1
6060
}
6161

62-
CLANG_MAJOR=$(sed -n 's/\s*set(LLVM_VERSION_MAJOR \([0-9]\+\))/\1/p' $LLVM_SRC_PATH/llvm/CMakeLists.txt)
63-
CLANG_MINOR=$(sed -n 's/\s*set(LLVM_VERSION_MINOR \([0-9]\+\))/\1/p' $LLVM_SRC_PATH/llvm/CMakeLists.txt)
64-
CLANG_PATCH=$(sed -n 's/\s*set(LLVM_VERSION_PATCH \([0-9]\+\))/\1/p' $LLVM_SRC_PATH/llvm/CMakeLists.txt)
62+
CLANG_MAJOR=$(sed -n 's/\s*set(LLVM_VERSION_MAJOR \([0-9]\+\))/\1/p' $LLVM_SRC_PATH/cmake/Modules/LLVMVersion.cmake)
63+
CLANG_MINOR=$(sed -n 's/\s*set(LLVM_VERSION_MINOR \([0-9]\+\))/\1/p' $LLVM_SRC_PATH/cmake/Modules/LLVMVersion.cmake)
64+
CLANG_PATCH=$(sed -n 's/\s*set(LLVM_VERSION_PATCH \([0-9]\+\))/\1/p' $LLVM_SRC_PATH/cmake/Modules/LLVMVersion.cmake)
6565
CLANG_VERSION="$CLANG_MAJOR.$CLANG_MINOR.$CLANG_PATCH"
6666
echo "Building CLANG_VERSION $CLANG_VERSION"
6767
echo "Building CC $CC"
@@ -79,7 +79,7 @@ set -x
7979

8080
RUN_CMAKE_CONFIG_STEP=true
8181
BUILD_RUNTIMES=true
82-
BUILD_LLVM=true
82+
BUILD_LLVM=true
8383

8484
# rerunning cmake configure on existing build doesn't work too well
8585
$RUN_CMAKE_CONFIG_STEP && $BUILD_RUNTIMES && rm -Rf "${BUILDDIR_TOOLCHAIN}/runtimes"
@@ -89,7 +89,7 @@ $RUN_CMAKE_CONFIG_STEP && $BUILD_RUNTIMES && cmake -Wno-dev --warn-uninitialized
8989
-B${BUILDDIR_TOOLCHAIN}/runtimes-memsan \
9090
-GNinja \
9191
-DCMAKE_BUILD_TYPE=Debug \
92-
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
92+
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
9393
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
9494
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}/runtimes-memsan" \
9595
-DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-unknown-linux-gnu" \
@@ -100,6 +100,9 @@ $RUN_CMAKE_CONFIG_STEP && $BUILD_RUNTIMES && cmake -Wno-dev --warn-uninitialized
100100
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxxabi;libcxx" \
101101
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
102102
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
103+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
104+
-DCOMPILER_RT_BUILD_BUILTINS=ON \
105+
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=FALSE \
103106
-DLLVM_ENABLE_LIBCXX=ON \
104107
-DLIBCXX_ABI_UNSTABLE=ON \
105108
-DLIBCXX_ENABLE_SHARED=ON \
@@ -143,6 +146,9 @@ $RUN_CMAKE_CONFIG_STEP && $BUILD_RUNTIMES && cmake -Wno-dev --warn-uninitialized
143146
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
144147
-DLIBCXXABI_INCLUDE_TESTS=OFF \
145148
-DLIBCXXABI_USE_COMPILER_RT=ON \
149+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
150+
-DCOMPILER_RT_BUILD_BUILTINS=ON \
151+
-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=FALSE \
146152
-DSANITIZER_CXX_ABI=libcxxabi \
147153
-DLLVM_ENABLE_ASSERTIONS=OFF \
148154
-DLLVM_INCLUDE_DOCS=OFF \
@@ -167,7 +173,7 @@ $RUN_CMAKE_CONFIG_STEP && $BUILD_LLVM && cmake -Wno-dev --warn-uninitialized \
167173
-DLLVM_HOST_TRIPLE="x86_64-unknown-linux-gnu" \
168174
-DCMAKE_C_COMPILER_TARGET="x86_64-unknown-linux-gnu" \
169175
-DCMAKE_CXX_COMPILER_TARGET="x86_64-unknown-linux-gnu" \
170-
-DCLANG_RESOURCE_DIR="../" \
176+
-DCLANG_RESOURCE_DIR="" \
171177
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
172178
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb;clang-tools-extra" \
173179
-DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF \
@@ -195,24 +201,28 @@ $RUN_CMAKE_CONFIG_STEP && $BUILD_LLVM && cmake -Wno-dev --warn-uninitialized \
195201
$BUILD_LLVM && cmake --build "${BUILDDIR_TOOLCHAIN}/toolchain" --parallel 6 --target llvm-tblgen
196202
$BUILD_LLVM && cmake --build "${BUILDDIR_TOOLCHAIN}/toolchain" --parallel 9 --target install/strip
197203

198-
cd $INSTALL_PREFIX
199-
# There is no way to configure the install directory for these headers
200-
# so we move them manully
201-
if [ $BUILD_LLVM ] && [ -d "lib/clang/$CLANG_VERSION/include" ]; then
202-
rsync -va lib/clang/$CLANG_VERSION/include/ include/
203-
rm -Rf lib/clang
204-
fi
205-
if [ $BUILD_LLVM ] && [ -d "lib/clang/$CLANG_MAJOR/include" ]; then
206-
rsync -va lib/clang/$CLANG_MAJOR/include/ include/
207-
rm -Rf lib/clang
204+
# the install prefix for the compiler-rt builtin .a files is not correct
205+
# fix it manually for now
206+
if [ -d "${INSTALL_PREFIX}/lib/clang/19" ]; then
207+
pushd "${INSTALL_PREFIX}/lib/clang/19"
208+
if [ ! -d lib ]; then
209+
mkdir lib
210+
pushd lib
211+
ln -s ../../../x86_64-unknown-linux-gnu
212+
popd
213+
fi
214+
popd
208215
fi
209216

210-
# Now use the newly built libs for the compiler itself.
211-
# They are ABI compatible if this is a stage 2 build
212-
# cd lib
213-
# # rm libc++*
214-
# # rm libunwind*
215-
# rsync -va $BOOT_TC/lib/x86_64-unknown-linux-gnu/libc++.so.2 .
216-
# rsync -va $BOOT_TC/lib/x86_64-unknown-linux-gnu/libc++abi.so.1
217-
# cd ..
218-
# cd ..
217+
# steal the local runtimes and provide them for packaging, what is the worst that could happen?
218+
# in theory this should work
219+
cp /lib/x86_64-linux-gnu/libc++abi.so.1 /build/llvm/llvm-linux-x86_64/lib && \
220+
cp /lib/x86_64-linux-gnu/libc++.so.1 /build/llvm/llvm-linux-x86_64/lib && \
221+
cp /lib/x86_64-linux-gnu/libunwind.so.1 /build/llvm/llvm-linux-x86_64/lib
222+
223+
cp /lib/x86_64-linux-gnu/libncurses.so.6 /build/llvm/llvm-linux-x86_64/lib && \
224+
cp /lib/x86_64-linux-gnu/libform.so.6 /build/llvm/llvm-linux-x86_64/lib && \
225+
cp /lib/x86_64-linux-gnu/libtinfo.so.6 /build/llvm/llvm-linux-x86_64/lib && \
226+
cp /lib/x86_64-linux-gnu/libpanel.so.6 /build/llvm/llvm-linux-x86_64/lib
227+
228+
tar -cjSf toolchain.bz2 --transform "s%^llvm-linux-x86_64%llvm-clang-${CLANG_VERSION}-ubuntu-22.04-x86_64%" llvm-linux-x86_64

0 commit comments

Comments
 (0)