Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retire clang_version #451

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions cmake/wasi-sdk-sysroot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ option(WASI_SDK_INCLUDE_TESTS "Whether or not to build tests by default" 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)

# Force usage of the custom-built resource-dir and sysroot for the rest of the
# wasi compiles.
Expand Down Expand Up @@ -243,9 +243,17 @@ 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})
cmake_path(IS_PREFIX CMAKE_INSTALL_PREFIX ${clang_resource_dir} NORMALIZE install_resource_dir)
if(install_resource_dir)
install(DIRECTORY ${wasi_resource_dir}/lib
USE_SOURCE_PERMISSIONS
DESTINATION ${clang_resource_dir})
else()
message(STATUS "The resource dir (${clang_resource_dir}) will not be updated by the install target because it's out of CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}")
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This to me seems odd to me to have a conditional installation. Could an option be added to modify the host compiler's resource-dir and if that's turned off then the preexisting install location is used? (or something similar to it, probalby not the exact same structure with a clang version that isn't guaranteed to match something)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm a bit confused because i just tried to follow your suggestion and you are now saying it's odd. :-)

how about the last push?

Copy link
Collaborator

@alexcrichton alexcrichton Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first version of this PR unconditionally modified the host compiler resource-dir which I felt was surprising since it was modifying things outside of CMAKE_INSTALL_PREFIX. The second version of this PR, which this comment was targetting, did nothing by default and happened to install things if CMAKE_INSTALL_PREFIX lined up. I found that surprising as well because it's not documented and just a status message can be easily lost in configure output.

Third version of this PR makes more sense to me. Something is always installed and it always shows up somewhere, and an opt-in is enabled to perform a non-standard installation to put something outside of the installation prefix.


# Add a top-level `build` target as well as `build-$target` targets.
add_custom_target(build ALL)
Expand Down Expand Up @@ -279,7 +287,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
Expand Down
Loading