Skip to content

Commit 588acfb

Browse files
authored
[Clang][CI] Extend clang version output (#20520)
There is a customer request to make `clang++ --version` output more informative. This patch adds a string like this to the output: "Intel SYCL compiler X build based on:" - here goes regular clang output. Where X is "development" by default. "Nightly YYYY-MM-DD" for regular nightly builds. "X.Y.Z Nightly YYYY-MM-DD" for nightly release builds. "X.Y.Z release" for official releases. E.g.: ``` Intel SYCL compiler development build based on: clang version 22.0.0git (https://github.com/intel/llvm.git 479b59d) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /localdisk2/llvm/build/bin Build config: +assertions ```
1 parent bfcbb2f commit 588acfb

File tree

9 files changed

+38
-5
lines changed

9 files changed

+38
-5
lines changed

.github/workflows/sycl-linux-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ jobs:
209209
id: build
210210
# Emulate default value for manual dispatch as we've run out of available arguments.
211211
run: cmake --build $GITHUB_WORKSPACE/build --target ${{ inputs.build_target || 'sycl-toolchain' }}
212+
- run: $GITHUB_WORKSPACE/build/bin/clang++ --version
212213
- name: check-llvm
213214
if: ${{ !cancelled() && contains(inputs.changes, 'llvm') }}
214215
env:

.github/workflows/sycl-nightly.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ jobs:
2323
git diff --exit-code -I "^# RUN" origin/sycl-rel-6_3:sycl/test/abi/sycl_symbols_linux.dump sycl/test/abi/sycl_symbols_linux-sycl-rel-6_3.dump
2424
git diff --exit-code -I "^# RUN" origin/sycl-rel-6_3:sycl/test/abi/sycl_symbols_windows.dump sycl/test/abi/sycl_symbols_windows-sycl-rel-6_3.dump
2525
26+
get_date:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
date: ${{ steps.get_date.outputs.date }}
30+
steps:
31+
- id: get_date
32+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
33+
2634
ubuntu2204_build:
35+
needs: get_date
2736
if: github.repository == 'intel/llvm'
2837
uses: ./.github/workflows/sycl-linux-build.yml
2938
secrets: inherit
3039
with:
3140
build_cache_root: "/__w/"
32-
build_configure_extra_args: '--hip --cuda'
41+
build_configure_extra_args: '--hip --cuda -DSYCL_BUILD_INFO="Nightly ${{ needs.get_date.outputs.date }}"'
3342
build_image: ghcr.io/intel/llvm/ubuntu2204_build:latest
3443

3544
retention-days: 90
@@ -189,6 +198,7 @@ jobs:
189198
toolchain_decompress_command: ${{ needs.ubuntu2404_oneapi_build.outputs.toolchain_decompress_command }}
190199

191200
build-win:
201+
needs: get_date
192202
uses: ./.github/workflows/sycl-windows-build.yml
193203
if: github.repository == 'intel/llvm'
194204
with:
@@ -197,7 +207,7 @@ jobs:
197207
# functionality, make sure Linux/Windows names follow the same pattern.
198208
toolchain_artifact_filename: sycl_windows.tar.gz
199209
# Disable the spirv-dis requirement as to not require SPIR-V Tools.
200-
build_configure_extra_args: -DLLVM_SPIRV_ENABLE_LIBSPIRV_DIS=off
210+
build_configure_extra_args: -DLLVM_SPIRV_ENABLE_LIBSPIRV_DIS=off -DSYCL_BUILD_INFO="Nightly ${{ needs.get_date.outputs.date }}"
201211
build_target: all
202212

203213
e2e-win:
@@ -358,7 +368,7 @@ jobs:
358368
nightly_build_upload:
359369
name: Nightly Build Upload
360370
if: ${{ github.ref_name == 'sycl' }}
361-
needs: [ubuntu2204_build, build-win]
371+
needs: [get_date, ubuntu2204_build, build-win]
362372
runs-on: ubuntu-latest
363373
permissions:
364374
contents: write
@@ -378,10 +388,10 @@ jobs:
378388
id: tag
379389
run: |
380390
if [ "${{ github.event_name == 'schedule' }}" == "true" ]; then
381-
echo "TAG=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
391+
echo "TAG=${{ needs.get_date.outputs.date }}" >> "$GITHUB_OUTPUT"
382392
else
383393
# TODO: Use date of the commit?
384-
echo "TAG=$(date +'%Y-%m-%d')-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
394+
echo "TAG=${{ needs.get_date.outputs.date }}-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
385395
fi
386396
- name: Upload binaries
387397
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1

.github/workflows/sycl-windows-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ jobs:
159159
shell: bash
160160
run: |
161161
cmake --build build --target ${{ inputs.build_target }}
162+
- run: build/bin/clang++ --version
162163
- name: check-llvm
163164
if: ${{ !cancelled() && contains(inputs.changes, 'llvm') }}
164165
shell: bash

clang/include/clang/Basic/Version.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ namespace clang {
6666
/// the CL_SYCL_LANGUAGE_VERSION and SYCL_LANGUAGE_VERSION macros.
6767
llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 2>
6868
getSYCLVersionMacros(const LangOptions &LangOpts);
69+
70+
/// Retrieves a string representing the Intel SYCL compiler build info.
71+
std::string getSYCLBuildInfo();
6972
}
7073

7174
#endif // LLVM_CLANG_BASIC_VERSION_H

clang/lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ add_custom_command(OUTPUT "${version_inc}"
4242
"-DLLVM_VC_REVISION=${llvm_vc_revision}"
4343
"-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
4444
"-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
45+
"-DSYCL_BUILD_INFO=${SYCL_BUILD_INFO}"
4546
-P "${generate_vcs_version_script}")
4647

4748
# Mark the generated header as being generated.

clang/lib/Basic/Version.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ std::string getClangVendor() {
6565
#endif
6666
}
6767

68+
std::string getSYCLBuildInfo() {
69+
#ifdef SYCL_BUILD_INFO
70+
return SYCL_BUILD_INFO;
71+
#else
72+
return "development";
73+
#endif
74+
}
75+
6876
std::string getClangFullRepositoryVersion() {
6977
std::string buf;
7078
llvm::raw_string_ostream OS(buf);

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,7 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
27352735
}
27362736

27372737
void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
2738+
OS << "Intel SYCL compiler " << getSYCLBuildInfo() << " build based on:\n";
27382739
if (IsFlangMode()) {
27392740
OS << getClangToolFullVersion("flang") << '\n';
27402741
} else {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %clang --version 2>&1 | FileCheck %s
2+
3+
// CHECK: Intel SYCL compiler{{.*}}based on:

llvm/cmake/modules/GenerateVersionFromVCS.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ foreach(name IN LISTS NAMES)
5656
append_info(${name} "${revision}" "${repository}")
5757
endforeach()
5858

59+
if(SYCL_BUILD_INFO)
60+
file(APPEND "${HEADER_FILE}.tmp"
61+
"#define SYCL_BUILD_INFO \"${SYCL_BUILD_INFO}\"\n")
62+
endif()
63+
5964
# Copy the file only if it has changed.
6065
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
6166
"${HEADER_FILE}.tmp" "${HEADER_FILE}")

0 commit comments

Comments
 (0)