Skip to content

Commit 36a0a5d

Browse files
authored
Add support for building ancient Clang (2.6-4.0) (#84)
This PR adds support for building Clang 2.6 through 4.0 using Ubuntu 16.04, aiming to replace third-party binaries I provided for compiler-explorer/infra@8123801. At the high level, changes are: 1. Support for Ubuntu 16.04 in the Dockerfile. 2. New mechanism to cherry-pick commits into the tree (`COMMITS_TO_CHERRYPICK`). 3. Special sections for 2.6-3.7, where we hardcode GCC version, commits to cherry-pick, patches to apply, and names of test targets. 4. Logic that translates `LLVM_ENABLE_PROJECTS` into the directory structure that old versions expect using symbolic links. 5. New testing that checks that just-built Clang is capable of compiling C++ hello world both with and without `-stdlib=libc++`, and that `libc++.so` is good enough for it to run successfully. 6. Patch files, mostly for cherry-picks that don't apply cleanly. <details> <summary>Test results (passes are the first number, failures are the fourth number):</summary> The order is: - Expected Passes - Expected Failures - Unsupported Tests - Unexpected Failures - Unexpected Passes </details> | Clang | GCC | LLVM tests | Clang tests | Libc++ tests | |---------|-------|---------------------|-------------------|--------------------| | 2.6.0 | 4.4.7 | N/A via CMake | 1463 0 0 0 | N/A | | 2.7.0 | 4.4.7 | 4294 23 514 26 | 2090 13 0 0 | N/A | | 2.8.0 | 4.5.3 | 4562 28 552 94 | 2505 19 0 1 | N/A | | 2.9.0 | 4.5.3 | 5262 46 542 0 | 2884 22 0 2 | N/A | | 3.0.0 | 4.4.7 | 5590 49 13 0 | 3913 25 1 2 | N/A | | 3.1.0 | 4.4.7 | 5823 51 13 0 | 4537 27 0 2 | N/A | | 3.2.0 | 4.4.7 | 6781 56 13 0 | 5565 25 2 1 | Can't build | | 3.3.0 | 4.8.5 | 8483 54 99 0 | 6216 22 4 2 | 3315 0 0 1075 0 | | 3.4.0 | 4.8.5 | 9239 51 34 0 | 6770 20 5 2 | 4058 0 0 585 0 | | 3.5.0 | 4.9.4 | 11131 90 35 0 | 7492 14 11 0 | 4490 0 0 260 0 | | 3.6.0 | 4.9.4 | 12138 83 55 0 | 7924 14 13 0 | 4640 11 69 68 3 | | 3.7.0 | 5.5 | 14025 105 46 0 | 8374 14 15 0 | 4751 20 125 31 3 | | 3.8.0 | 5.5 | 15387 129 100 0 | 8847 16 17 0 | 4869 4 107 42 4 | | 3.9.0 | 5.5 | 17093 128 149 0 | 9597 16 23 0 | 5218 5 111 33 0 | | 4.0.0 | 5.5 | 18806 151 381 0 | 10313 18 34 0 | 5038 24 645 19 0 | (Note that libc++ runs its tests using the compiler it was built with, i.e. GCC, so bad results are not caused by a bad Clang build. Which means they are not representative of the experience people will have using `-stdlib=libc++`.) Those results are directly comparable with those I have for the binaries that are currently deployed: https://gist.github.com/Endilll/d36e4080b68d682e2b9fd96980cfb40a. While libc++ seems to be worse, it doesn't really matter as outlined above. Overall, the builds this script produces should be on par, if not slightly better, than the ones I did 2 years ago.
1 parent 9dab861 commit 36a0a5d

12 files changed

+1012
-16
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
# Some older clangs (<10) needs to be an older glibc, as comes with 18.04 in order to build 9.* and earlier.
1616
# otherwise we somehow need to apply 947f9692440836dcb8d88b74b69dd379d85974ce to get the sanitizer
1717
# to build.
18+
- image: 16.04
19+
suffix: -16.4
20+
# Ancient Clang builds (2.6-4.0) assume 16.04 environment.
1821
steps:
1922
- name: Docker Setup Buildx
2023
uses: docker/setup-buildx-action@v3

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ RUN apt update -y -q && apt upgrade -y -q && apt update -y -q && \
2828
xz-utils \
2929
zlib1g-dev
3030

31-
RUN bash -c "if [[ ${image} == 18.04 ]]; then apt install -y -q python; else apt install -y -q python-is-python3; fi"
31+
RUN bash -c "if [[ ${image} == 16.04 || ${image} == 18.04 ]]; then apt install -y -q python; else apt install -y -q python-is-python3; fi"
3232

3333
WORKDIR /root
3434

3535
RUN curl -sL https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-Linux-x86_64.tar.gz \
3636
| tar zxvf - -C /usr --strip-components=1
3737

3838
# Workaround for older clangs that expect xlocale.h
39-
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
39+
RUN bash -c "if [[ ${image} != 16.04 ]]; then ln -s /usr/include/locale.h /usr/include/xlocale.h; fi"
4040

4141
RUN mkdir -p /root
4242
COPY build /root/

build/build.sh

Lines changed: 247 additions & 14 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
This is 95b6f045f1f104b96d443c404755c2757b6f6cf7
2+
"Use a script for creating the clang++ executable.",
3+
backported to 2.7
4+
5+
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
6+
index c4320b0c905c..78789201438a 100644
7+
--- a/clang/tools/driver/CMakeLists.txt
8+
+++ b/clang/tools/driver/CMakeLists.txt
9+
@@ -45,4 +45,4 @@ install(TARGETS clang
10+
RUNTIME DESTINATION bin)
11+
12+
# Create the clang++ symlink at installation time.
13+
-install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E ${CLANGXX_LINK_OR_COPY} \"${CMAKE_INSTALL_PREFIX}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}\" \"\$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}\")")
14+
+install(SCRIPT clang_symlink.cmake -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
15+
diff --git a/clang/tools/driver/clang_symlink.cmake b/clang/tools/driver/clang_symlink.cmake
16+
new file mode 100644
17+
index 00000000000000..d3f11d313ef49b
18+
--- /dev/null
19+
+++ b/clang/tools/driver/clang_symlink.cmake
20+
@@ -0,0 +1,18 @@
21+
+# We need to execute this script at installation time because the
22+
+# DESTDIR environment variable may be unset at configuration time.
23+
+# See PR8397.
24+
+
25+
+if(UNIX)
26+
+ set(CLANGXX_LINK_OR_COPY create_symlink)
27+
+ set(CLANGXX_DESTDIR $ENV{DESTDIR})
28+
+else()
29+
+ set(CLANGXX_LINK_OR_COPY copy)
30+
+endif()
31+
+
32+
+set(bindir "${CLANGXX_DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
33+
+set(clang "${bindir}clang${CMAKE_EXECUTABLE_SUFFIX}")
34+
+set(clangxx "${bindir}clang++${CMAKE_EXECUTABLE_SUFFIX}")
35+
+
36+
+message("Creating clang++ executable based on ${clang}")
37+
+
38+
+execute_process(COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clangxx}")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Clang 2.7 was caught between removal of the old clang-cc driver
2+
(3c6d1b52a09a6a94384b27840d64451d4fa292f3), and proper implementation of
3+
`-mllvm` that passes arguments to backend
4+
(76fa840d0990314d1d1c160803ba9d014a6c01a9). There appears to be no way to pass
5+
`-x86-asm-syntax` to the backend, so we're forced to change the default.
6+
7+
diff --git a/llvm/lib/Target/X86/X86MCAsmInfo.cpp b/llvm/lib/Target/X86/X86MCAsmInfo.cpp
8+
index ded9717..b828945 100644
9+
--- a/llvm/lib/Target/X86/X86MCAsmInfo.cpp
10+
+++ b/llvm/lib/Target/X86/X86MCAsmInfo.cpp
11+
@@ -25,7 +25,7 @@ enum AsmWriterFlavorTy {
12+
};
13+
14+
static cl::opt<AsmWriterFlavorTy>
15+
-AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
16+
+AsmWriterFlavor("x86-asm-syntax", cl::init(Intel),
17+
cl::desc("Choose style of code to emit from X86 backend:"),
18+
cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
19+
clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
This is 5a3d898758ed87f5d58e92d3ecdb75b567b059d6
2+
"Make the Linux support for finding libc++ somewhat less braindead.",
3+
backported to 3.3
4+
5+
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
6+
index fffba0e4e50f..87a5a9c99794 100644
7+
--- a/clang/lib/Driver/ToolChains.cpp
8+
+++ b/clang/lib/Driver/ToolChains.cpp
9+
@@ -2555,9 +2555,24 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
10+
11+
// Check if libc++ has been enabled and provide its include paths if so.
12+
if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
13+
- // libc++ is always installed at a fixed path on Linux currently.
14+
- addSystemInclude(DriverArgs, CC1Args,
15+
- getDriver().SysRoot + "/usr/include/c++/v1");
16+
+ const std::string LibCXXIncludePathCandidates[] = {
17+
+ // The primary location is within the Clang installation.
18+
+ // FIXME: We shouldn't hard code 'v1' here to make Clang future proof to
19+
+ // newer ABI versions.
20+
+ getDriver().Dir + "/../include/c++/v1",
21+
+
22+
+ // We also check the system as for a long time this is the only place Clang looked.
23+
+ // FIXME: We should really remove this. It doesn't make any sense.
24+
+ getDriver().SysRoot + "/usr/include/c++/v1"
25+
+ };
26+
+ for (unsigned i = 0; i < llvm::array_lengthof(LibCXXIncludePathCandidates);
27+
+ ++i) {
28+
+ if (!llvm::sys::fs::exists(LibCXXIncludePathCandidates[i]))
29+
+ continue;
30+
+ // Add the first candidate that exists.
31+
+ addSystemInclude(DriverArgs, CC1Args, LibCXXIncludePathCandidates[i]);
32+
+ break;
33+
+ }
34+
return;
35+
}
36+
37+
@@ -2581,7 +2596,7 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
38+
DriverArgs, CC1Args))
39+
return;
40+
41+
- const std::string IncludePathCandidates[] = {
42+
+ const std::string LibStdCXXIncludePathCandidates[] = {
43+
// Gentoo is weird and places its headers inside the GCC install, so if the
44+
// first attempt to find the headers fails, try this pattern.
45+
InstallDir.str() + "/include/g++-v4",
46+
@@ -2592,8 +2607,8 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
47+
LibDir.str() + "/../include/c++",
48+
};
49+
50+
- for (unsigned i = 0; i < llvm::array_lengthof(IncludePathCandidates); ++i) {
51+
- if (addLibStdCXXIncludePaths(IncludePathCandidates[i], (TripleStr +
52+
+ for (unsigned i = 0; i < llvm::array_lengthof(LibStdCXXIncludePathCandidates); ++i) {
53+
+ if (addLibStdCXXIncludePaths(LibStdCXXIncludePathCandidates[i], (TripleStr +
54+
GCCInstallation.getMultiarchSuffix()),
55+
DriverArgs, CC1Args))
56+
break;
57+
diff --git a/clang/test/Driver/linux-header-search.cpp b/clang/test/Driver/linux-header-search.cpp
58+
index d09f5b27ae9d..57e245baa3d8 100644
59+
--- a/clang/test/Driver/linux-header-search.cpp
60+
+++ b/clang/test/Driver/linux-header-search.cpp
61+
@@ -1,6 +1,29 @@
62+
// General tests that the header search paths detected by the driver and passed
63+
// to CC1 are sane.
64+
//
65+
+// Test a simulated installation of libc++ on Linux, both through sysroot and
66+
+// the installation path of Clang.
67+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
68+
+// RUN: -target x86_64-unknown-linux-gnu \
69+
+// RUN: -stdlib=libc++ \
70+
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
71+
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
72+
+// RUN: | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-SYSROOT %s
73+
+// CHECK-BASIC-LIBCXX-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
74+
+// CHECK-BASIC-LIBCXX-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]"
75+
+// CHECK-BASIC-LIBCXX-SYSROOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
76+
+// CHECK-BASIC-LIBCXX-SYSROOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
77+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
78+
+// RUN: -target x86_64-unknown-linux-gnu \
79+
+// RUN: -stdlib=libc++ \
80+
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
81+
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
82+
+// RUN: | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-INSTALL %s
83+
+// CHECK-BASIC-LIBCXX-INSTALL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
84+
+// CHECK-BASIC-LIBCXX-INSTALL: "-isysroot" "[[SYSROOT:[^"]+]]"
85+
+// CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" "[[SYSROOT]]/usr/bin/../include/c++/v1"
86+
+// CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
87+
+//
88+
// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
89+
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
90+
// RUN: -target i386-unknown-linux \
91+
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
This is 8241405ad42a8ce85c2a61baff5f96948f90cfa6
2+
"[libcxx] Make it drastically simpler to link libc++.",
3+
combined with a follow-up fix from
4+
a15785bb5b644d92ea27b247d01be4f87b46307c
5+
"Re-enable linker scripts after fixing bad CMake",
6+
backported to 3.5.
7+
8+
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
9+
index c20e5d1cc2a0..6cdfefb4e9e3 100644
10+
--- a/libcxx/CMakeLists.txt
11+
+++ b/libcxx/CMakeLists.txt
12+
@@ -52,6 +52,11 @@ set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
13+
"Specify C++ ABI library to use." FORCE)
14+
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
15+
16+
+# Generate and install a linker script inplace of libc++.so. The linker script
17+
+# will link libc++ to the correct ABI library.
18+
+option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
19+
+ "Use and install a linker script for the given ABI library" OFF)
20+
+
21+
#===============================================================================
22+
# Configure System
23+
#===============================================================================
24+
@@ -71,6 +76,21 @@ get_target_triple(LIBCXX_TARGET_TRIPLE
25+
)
26+
set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
27+
28+
+if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
29+
+ if (APPLE)
30+
+ message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets")
31+
+ endif()
32+
+ if (NOT PYTHONINTERP_FOUND)
33+
+ message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.")
34+
+ endif()
35+
+endif()
36+
+
37+
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
38+
+ message(FATAL_ERROR "Conflicting options given.
39+
+ LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with
40+
+ LIBCXX_ENABLE_ABI_LINKER_SCRIPT")
41+
+endif()
42+
+
43+
#===============================================================================
44+
# Add an ABI library if appropriate
45+
#===============================================================================
46+
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
47+
index 70adcb722132..1c04b9b1b088 100644
48+
--- a/libcxx/lib/CMakeLists.txt
49+
+++ b/libcxx/lib/CMakeLists.txt
50+
@@ -95,7 +95,36 @@ set_target_properties(cxx
51+
SOVERSION "1"
52+
)
53+
54+
+# Generate a linker script inplace of a libc++.so symlink. Rerun this command
55+
+# after cxx builds.
56+
+if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
57+
+ # Get the name of the ABI library and handle the case where CXXABI_LIBNAME
58+
+ # is a target name and not a library. Ex cxxabi_shared.
59+
+ set(SCRIPT_ABI_LIBNAME "${CXXABI_LIBNAME}")
60+
+ if (SCRIPT_ABI_LIBNAME STREQUAL "cxxabi")
61+
+ set(SCRIPT_ABI_LIBNAME "c++abi")
62+
+ endif()
63+
+ # Generate a linker script inplace of a libc++.so symlink. Rerun this command
64+
+ # after cxx builds.
65+
+ add_custom_command(TARGET cxx POST_BUILD
66+
+ COMMAND
67+
+ ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../utils/gen_link_script/gen_link_script.py
68+
+ ARGS
69+
+ "$<TARGET_LINKER_FILE:cxx>"
70+
+ "${SCRIPT_ABI_LIBNAME}"
71+
+ WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
72+
+ )
73+
+endif()
74+
+
75+
+
76+
install(TARGETS cxx
77+
LIBRARY DESTINATION lib
78+
ARCHIVE DESTINATION lib
79+
)
80+
+# NOTE: This install command must go after the cxx install command otherwise
81+
+# it will not be executed after the library symlinks are installed.
82+
+if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
83+
+ install(FILES "$<TARGET_LINKER_FILE:cxx>"
84+
+ DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
85+
+ COMPONENT libcxx)
86+
+endif()
87+
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
88+
index 4810b2c57483..6673197b0d4e 100644
89+
--- a/libcxx/test/CMakeLists.txt
90+
+++ b/libcxx/test/CMakeLists.txt
91+
@@ -30,6 +30,17 @@ if(PYTHONINTERP_FOUND)
92+
pythonize_bool(LIBCXX_ENABLE_SHARED)
93+
pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG)
94+
95+
+# The tests shouldn't link to any ABI library when it has been linked into
96+
+# libc++ statically or via a linker script.
97+
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
98+
+ set(LIBCXX_CXX_ABI_LIBNAME "none")
99+
+endif()
100+
+
101+
+set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
102+
+ "TargetInfo to use when setting up test environment.")
103+
+set(LIBCXX_EXECUTOR "None" CACHE STRING
104+
+ "Executor to use when running tests.")
105+
+
106+
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
107+
108+
configure_file(
109+
diff --git a/libcxx/utils/gen_link_script/gen_link_script.py b/libcxx/utils/gen_link_script/gen_link_script.py
110+
new file mode 100755
111+
index 000000000000..5de18f9129c6
112+
--- /dev/null
113+
+++ b/libcxx/utils/gen_link_script/gen_link_script.py
114+
@@ -0,0 +1,79 @@
115+
+#!/usr/bin/env python
116+
+import os
117+
+import sys
118+
+
119+
+def print_and_exit(msg):
120+
+ sys.stderr.write(msg + '\n')
121+
+ sys.exit(1)
122+
+
123+
+def usage_and_exit():
124+
+ print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] <path/to/libcxx.so> <abi_libname>")
125+
+
126+
+def help_and_exit():
127+
+ help_msg = \
128+
+"""Usage
129+
+
130+
+ gen_link_script.py [--help] [--dryrun] <path/to/libcxx.so> <abi_libname>
131+
+
132+
+ Generate a linker script that links libc++ to the proper ABI library.
133+
+ The script replaces the specified libc++ symlink.
134+
+ An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
135+
+
136+
+Arguments
137+
+ <path/to/libcxx.so> - The top level symlink to the versioned libc++ shared
138+
+ library. This file is replaced with a linker script.
139+
+ <abi_libname> - The name of the ABI library to use in the linker script.
140+
+ The name must be one of [c++abi, stdc++, supc++, cxxrt].
141+
+
142+
+Exit Status:
143+
+ 0 if OK,
144+
+ 1 if the action failed.
145+
+"""
146+
+ print_and_exit(help_msg)
147+
+
148+
+def parse_args():
149+
+ args = list(sys.argv)
150+
+ del args[0]
151+
+ if len(args) == 0:
152+
+ usage_and_exit()
153+
+ if args[0] == '--help':
154+
+ help_and_exit()
155+
+ dryrun = '--dryrun' == args[0]
156+
+ if dryrun:
157+
+ del args[0]
158+
+ if len(args) != 2:
159+
+ usage_and_exit()
160+
+ symlink_file = args[0]
161+
+ abi_libname = args[1]
162+
+ return dryrun, symlink_file, abi_libname
163+
+
164+
+def main():
165+
+ dryrun, symlink_file, abi_libname = parse_args()
166+
+
167+
+ # Check that the given libc++.so file is a valid symlink.
168+
+ if not os.path.islink(symlink_file):
169+
+ print_and_exit("symlink file %s is not a symlink" % symlink_file)
170+
+
171+
+ # Read the symlink so we know what libc++ to link to in the linker script.
172+
+ linked_libcxx = os.readlink(symlink_file)
173+
+
174+
+ # Check that the abi_libname is one of the supported values.
175+
+ supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
176+
+ if abi_libname not in supported_abi_list:
177+
+ print_and_exit("abi name '%s' is not supported: Use one of %r" %
178+
+ (abi_libname, supported_abi_list))
179+
+
180+
+ # Generate the linker script contents and print the script and destination
181+
+ # information.
182+
+ contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
183+
+ print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
184+
+
185+
+ # Remove the existing libc++ symlink and replace it with the script.
186+
+ if not dryrun:
187+
+ os.unlink(symlink_file)
188+
+ with open(symlink_file, 'w') as f:
189+
+ f.write(contents + "\n")
190+
+
191+
+
192+
+if __name__ == '__main__':
193+
+ main()
194+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Fix for 4814291e17ef501afa4c19ca43fbb52cfe49957c,
2+
which was a bad backport of 6fe361c1efc9e7c38c164fc6469857a84d3cb299
3+
"Remove use of _[A-Z] identifiers and poison them to detect usage"
4+
against release/3.6.x branch.
5+
6+
diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py
7+
index 55916f0da53e..4342a797abad 100644
8+
--- a/libcxx/test/libcxx/test/config.py
9+
+++ b/libcxx/test/libcxx/test/config.py
10+
@@ -269,8 +269,8 @@ class Configuration(object):
11+
# Configure include paths
12+
self.compile_flags += ['-nostdinc++']
13+
support_path = os.path.join(self.src_root, 'test/support')
14+
- self.cxx.compile_flags += ['-I' + support_path]
15+
- self.cxx.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
16+
+ self.compile_flags += ['-I' + support_path]
17+
+ self.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
18+
libcxx_headers = self.get_lit_conf('libcxx_headers',
19+
self.src_root + '/include')
20+
if not os.path.isdir(libcxx_headers):
21+

0 commit comments

Comments
 (0)