From e4fef74fee3d3849339b6c492f2dafe229891364 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 24 Jul 2024 05:31:44 +0900 Subject: [PATCH] Retire clang_version (#451) * Retire clang_version Note: this makes the "install" target install the compiler rt into the compiler's runtime directory. IMO, it's what "install" is supposed to do. If you want to avoid modifing the runtime directory for some reasons, you can still do "dist" without "install". * wasi-sdk-sysroot.cmake: Avoid modifying things out of CMAKE_INSTALL_PREFIX * wasi-sdk-sysroot.cmake: control the resource-dir modification by a cmake option --- CMakeLists.txt | 5 ----- cmake/wasi-sdk-sysroot.cmake | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90abca435..b39f21d0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,16 +24,11 @@ find_program(PYTHON python3 python REQUIRED) # Set some variables based on the `version.py` script set(version_script ${CMAKE_CURRENT_SOURCE_DIR}/version.py) -execute_process( - COMMAND ${PYTHON} ${version_script} llvm-major --llvm-dir=${llvm_proj_dir} - OUTPUT_VARIABLE clang_version - OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND ${PYTHON} ${version_script} OUTPUT_VARIABLE wasi_sdk_version OUTPUT_STRIP_TRAILING_WHITESPACE) -message(STATUS "wasi-sdk toolchain LLVM version is ${clang_version}") message(STATUS "wasi-sdk version is ${wasi_sdk_version}") # Only include one version of the build logic as pulling in both isn't diff --git a/cmake/wasi-sdk-sysroot.cmake b/cmake/wasi-sdk-sysroot.cmake index eea357a38..7e7345b0f 100644 --- a/cmake/wasi-sdk-sysroot.cmake +++ b/cmake/wasi-sdk-sysroot.cmake @@ -9,10 +9,11 @@ find_program(MAKE make REQUIRED) option(WASI_SDK_DEBUG_PREFIX_MAP "Pass `-fdebug-prefix-map` for built artifacts" ON) option(WASI_SDK_INCLUDE_TESTS "Whether or not to build tests by default" OFF) +option(WASI_SDK_INSTALL_TO_CLANG_RESOURCE_DIR "Whether or not to modify the compiler's resource directory" OFF) set(wasi_tmp_install ${CMAKE_CURRENT_BINARY_DIR}/install) set(wasi_sysroot ${wasi_tmp_install}/share/wasi-sysroot) -set(wasi_resource_dir ${wasi_tmp_install}/lib/clang/${clang_version}) +set(wasi_resource_dir ${wasi_tmp_install}/wasi-resource-dir) if(WASI_SDK_DEBUG_PREFIX_MAP) add_compile_options( @@ -246,9 +247,18 @@ endforeach() # misc build logic # ============================================================================= -install(DIRECTORY ${wasi_tmp_install}/lib ${wasi_tmp_install}/share +install(DIRECTORY ${wasi_tmp_install}/share USE_SOURCE_PERMISSIONS DESTINATION ${CMAKE_INSTALL_PREFIX}) +if(WASI_SDK_INSTALL_TO_CLANG_RESOURCE_DIR) + install(DIRECTORY ${wasi_resource_dir}/lib + USE_SOURCE_PERMISSIONS + DESTINATION ${clang_resource_dir}) +else() + install(DIRECTORY ${wasi_resource_dir}/lib + USE_SOURCE_PERMISSIONS + DESTINATION ${CMAKE_INSTALL_PREFIX}/clang-resource-dir) +endif() # Add a top-level `build` target as well as `build-$target` targets. add_custom_target(build ALL) @@ -282,7 +292,7 @@ set(dist_dir ${CMAKE_CURRENT_BINARY_DIR}/dist) # Tarball with just `compiler-rt` builtins within it wasi_sdk_add_tarball(dist-compiler-rt ${dist_dir}/libclang_rt.builtins-wasm32-wasi-${wasi_sdk_version}.tar.gz - ${wasi_tmp_install}/lib/clang/${clang_version}/lib/wasi) + ${wasi_resource_dir}/lib/wasi) add_dependencies(dist-compiler-rt compiler-rt) # Tarball with the whole sysroot