toolchain: Avoid using system headers on later (lib-)clang (#767)

This commit is contained in:
MonsterDruide1 2025-10-21 15:16:53 +02:00 committed by GitHub
parent da1ecd03de
commit 0904a18cc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 6 deletions

View file

@ -51,7 +51,7 @@ jobs:
key: tools_libs
path: |
toolchain/bin
toolchain/include
toolchain/libcxx-include
toolchain/cache-version-url.txt
- name: Run setup
run: tools/setup.py smo-main.nso

View file

@ -26,7 +26,7 @@ jobs:
key: tools_libs
path: |
toolchain/bin
toolchain/include
toolchain/libcxx-include
toolchain/cache-version-url.txt
- name: Run simplified setup
run: tools/setup.py --project

2
.gitignore vendored
View file

@ -50,6 +50,8 @@ perf.data.old
# Tooling
/toolchain/clang-*
!/toolchain/clang-include
toolchain/libcxx-include
toolchain/include
toolchain/cache-version-url.txt
tools/check

View file

@ -47,6 +47,13 @@ add_compile_options(-fPIC)
# Helps with matching as this causes Clang to emit debug type info even for dynamic classes
# with undefined vtables.
add_compile_options(-fstandalone-debug)
# avoids reading system-wide headers on later clang versions (for example linter's libclang)
add_compile_options(--gcc-toolchain=/nonexistant)
# after all other includes, use fallback clang headers
# => applied only when building this project normally, using system-wide (lib-)clang will use its own
add_compile_options(-idirafter ${CMAKE_CURRENT_LIST_DIR}/clang-include)
# custom libc++, provided in combination with clang-3.9.1
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/libcxx-include)
add_definitions(-D SWITCH)
add_definitions(-D NNSDK)
@ -56,5 +63,3 @@ add_link_options(-stdlib=libc++ -nostdlib)
add_link_options(-fPIC -Wl,-Bsymbolic-functions -shared)
# Use lld for performance reasons (and because we don't want a dependency on GNU tools)
add_link_options(-fuse-ld=${ODYSSEY_CLANG_LLD})
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/include)

View file

@ -126,14 +126,18 @@ def setup_project_tools(tools_from_source):
os.symlink(f"{get_repo_root()}/toolchain/bin/listsym", f"{get_repo_root()}/tools/listsym")
with tempfile.TemporaryDirectory() as tmpdir:
if not exists_toolchain_file("include/__config"):
if exists_toolchain_file("include/__config"): # old path to libcxx headers => moved to `libcxx-include`
print("Removing old libc++ headers...")
shutil.rmtree(f"{get_repo_root()}/toolchain/include")
if not exists_toolchain_file("libcxx-include/__config"):
print(">>> Downloading llvm-3.9 libc++ headers...")
path = tmpdir + "/libcxx-3.9.1.src.tar.xz"
urllib.request.urlretrieve(LIBCXX_SRC_URL, path)
print(">>> Extracting libc++ headers...")
with tarfile.open(path) as f:
f.extractall(tmpdir, filter='tar')
shutil.copytree(f"{tmpdir}/libcxx-3.9.1.src/include", f"{get_repo_root()}/toolchain/include", dirs_exist_ok=True)
shutil.copytree(f"{tmpdir}/libcxx-3.9.1.src/include", f"{get_repo_root()}/toolchain/libcxx-include", dirs_exist_ok=True)
if not exists_tool("check") or not exists_tool("decompme") or not exists_tool("listsym") or not exists_toolchain_file("bin/clang") or not exists_toolchain_file("bin/ld.lld"):