Skip to content

Commit 87e779f

Browse files
KornevNikitaelizabethandrewsykhatav
authored
[sycl-rel-7_0] Cherry-pick version-related patches (#21703)
Cherry-pick patches adding version macros: #21570 #21572 #21610 #21702 And also remove some info from the workflow file, since it's placed in the source code now. --------- Co-authored-by: elizabethandrews <elizabeth.andrews@intel.com> Co-authored-by: ykhatav <yashasvi.khatavkar@intel.com>
1 parent c3bfe4a commit 87e779f

12 files changed

Lines changed: 80 additions & 15 deletions

File tree

.github/workflows/sycl-rel-nightly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ jobs:
2323
echo "info=${{ inputs.sycl_build_info }}" >> $GITHUB_OUTPUT
2424
else
2525
date=$(date +'%Y-%m-%d')
26-
version="7.0.0"
27-
info="Nightly $date $version pre-release"
26+
info="Nightly $date"
2827
echo "info=$info" >> $GITHUB_OUTPUT
2928
fi
3029

clang/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION
351351
set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
352352
message(STATUS "Clang version: ${CLANG_VERSION}")
353353

354+
set(DPCPP_VERSION "${DPCPP_VERSION_MAJOR}.${DPCPP_VERSION_MINOR}.${DPCPP_VERSION_PATCH}")
355+
354356
# Configure the Version.inc file.
355357
configure_file(
356358
${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in

clang/include/clang/Basic/Version.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,17 @@ namespace clang {
6262
/// number, the repository version, and the vendor tag.
6363
std::string getClangFullCPPVersion();
6464

65+
/// Retrieves a string representing the complete DPC++ version suitable
66+
/// for use in the CPP __VERSION__ macro, including repository information.
67+
std::string getDPCPPFullCPPVersion();
68+
6569
/// Retrieves a string representing the SYCL standard version for use in
6670
/// the CL_SYCL_LANGUAGE_VERSION and SYCL_LANGUAGE_VERSION macros.
6771
llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 2>
6872
getSYCLVersionMacros(const LangOptions &LangOpts);
6973

70-
/// Retrieves a string representing the Intel SYCL compiler build info.
71-
std::string getSYCLBuildInfo();
74+
/// Retrieves a string representing the DPC++ Version.
75+
std::string getDPCPPVersion();
7276
}
7377

7478
#endif // LLVM_CLANG_BASIC_VERSION_H

clang/include/clang/Basic/Version.inc.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@
55
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
66
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
77
#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@
8+
#define DPCPP_VERSION_MAJOR @DPCPP_VERSION_MAJOR@
9+
#define DPCPP_VERSION_MINOR @DPCPP_VERSION_MINOR@
10+
#define DPCPP_VERSION_PATCH @DPCPP_VERSION_PATCH@
11+
#define DPCPP_VERSION "@DPCPP_VERSION@"
12+
#define PRE_RELEASE @PRE_RELEASE@

clang/lib/Basic/Version.cpp

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,25 @@ std::string getClangVendor() {
6565
#endif
6666
}
6767

68-
std::string getSYCLBuildInfo() {
68+
std::string getDPCPPPreReleaseInfo() {
69+
#if PRE_RELEASE
70+
std::string buf;
71+
llvm::raw_string_ostream OS(buf);
72+
OS << DPCPP_VERSION << " (pre-release)";
73+
return buf;
74+
#else
75+
return DPCPP_VERSION;
76+
#endif
77+
}
78+
79+
std::string getDPCPPVersion() {
6980
#ifdef SYCL_BUILD_INFO
70-
return SYCL_BUILD_INFO;
81+
std::string buf;
82+
llvm::raw_string_ostream OS(buf);
83+
OS << getDPCPPPreReleaseInfo() << " (" << SYCL_BUILD_INFO << ")";
84+
return buf;
7185
#else
72-
return "development";
86+
return getDPCPPPreReleaseInfo();
7387
#endif
7488
}
7589

@@ -132,6 +146,21 @@ std::string getClangFullCPPVersion() {
132146

133147
return buf;
134148
}
149+
std::string getDPCPPFullCPPVersion() {
150+
// Format: "DPC++ 6.3.0 git (https://github.com/intel/llvm.git ...)"
151+
std::string buf;
152+
llvm::raw_string_ostream OS(buf);
153+
OS << "DPC++ " DPCPP_VERSION;
154+
#if PRE_RELEASE
155+
OS << " (pre-release)";
156+
#endif
157+
std::string repo = getClangFullRepositoryVersion();
158+
if (!repo.empty()) {
159+
OS << " " << repo;
160+
}
161+
162+
return buf;
163+
}
135164

136165
llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 2>
137166
getSYCLVersionMacros(const LangOptions &LangOpts) {

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
27482748
}
27492749

27502750
void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
2751-
OS << "Intel SYCL compiler " << getSYCLBuildInfo() << " build based on:\n";
2751+
OS << "DPC++ compiler " << getDPCPPVersion() << " build based on:\n";
27522752
if (IsFlangMode()) {
27532753
OS << getClangToolFullVersion("flang") << '\n';
27542754
} else {

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -875,12 +875,18 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
875875
Builder.defineMacro("__clang_major__", TOSTR(CLANG_VERSION_MAJOR));
876876
Builder.defineMacro("__clang_minor__", TOSTR(CLANG_VERSION_MINOR));
877877
Builder.defineMacro("__clang_patchlevel__", TOSTR(CLANG_VERSION_PATCHLEVEL));
878-
#undef TOSTR
879-
#undef TOSTR2
880878
Builder.defineMacro("__clang_version__",
881879
"\"" CLANG_VERSION_STRING " "
882880
+ getClangFullRepositoryVersion() + "\"");
883881

882+
// DPC++ version macros - Intel's SYCL compiler
883+
Builder.defineMacro("__DPCPP__", "1");
884+
Builder.defineMacro("__dpcpp_major__", TOSTR(DPCPP_VERSION_MAJOR));
885+
Builder.defineMacro("__dpcpp_minor__", TOSTR(DPCPP_VERSION_MINOR));
886+
Builder.defineMacro("__dpcpp_patchlevel__", TOSTR(DPCPP_VERSION_PATCH));
887+
#undef TOSTR
888+
#undef TOSTR2
889+
884890
if (LangOpts.GNUCVersion != 0) {
885891
// Major, minor, patch, are given two decimal places each, so 4.2.1 becomes
886892
// 40201.
@@ -944,9 +950,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
944950
Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
945951

946952
// Previously this macro was set to a string aiming to achieve compatibility
947-
// with GCC 4.2.1. Now, just return the full Clang version
948-
Builder.defineMacro("__VERSION__", "\"" +
949-
Twine(getClangFullCPPVersion()) + "\"");
953+
// with GCC 4.2.1. Now, just return the full DPC++ version
954+
Builder.defineMacro("__VERSION__",
955+
"\"" + Twine(getDPCPPFullCPPVersion()) + "\"");
950956

951957
// Initialize language-specific preprocessor defines.
952958

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// RUN: %clang --version 2>&1 | FileCheck %s
22

3-
// CHECK: Intel SYCL compiler{{.*}}based on:
3+
// CHECK: DPC++ compiler {{.*}}based on:

clang/test/Preprocessor/init-aarch64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
// AARCH64-NEXT: #define __DBL_MIN__ 2.2250738585072014e-308
7979
// AARCH64-NEXT: #define __DBL_NORM_MAX__ 1.7976931348623157e+308
8080
// AARCH64-NEXT: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
81+
// AARCH64-NEXT: #define __DPCPP__ 1
8182
// AARCH64-NEXT: #define __ELF__ 1
8283
// AARCH64-NEXT: #define __FINITE_MATH_ONLY__ 0
8384
// AARCH64-NEXT: #define __FLT16_DECIMAL_DIG__ 5

clang/test/Preprocessor/init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@
11921192
// SPARC:#define __UINT_LEAST8_MAX__ 255
11931193
// SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
11941194
// SPARC:#define __USER_LABEL_PREFIX__
1195-
// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
1195+
// SPARC:#define __VERSION__ "{{.*}}DPC++{{.*}}
11961196
// SPARC:#define __WCHAR_MAX__ 2147483647
11971197
// SPARC:#define __WCHAR_TYPE__ int
11981198
// SPARC:#define __WCHAR_WIDTH__ 32
@@ -1715,6 +1715,7 @@
17151715
// WEBASSEMBLY-NEXT:#define __DBL_MIN__ 2.2250738585072014e-308
17161716
// WEBASSEMBLY-NEXT:#define __DBL_NORM_MAX__ 1.7976931348623157e+308
17171717
// WEBASSEMBLY-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
1718+
// WEBASSEMBLY-NEXT:#define __DPCPP__ 1
17181719
// WEBASSEMBLY-NOT:#define __ELF__
17191720
// EMSCRIPTEN-THREADS-NEXT:#define __EMSCRIPTEN_PTHREADS__ 1
17201721
// EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1
@@ -2078,6 +2079,9 @@
20782079
// WEBASSEMBLY-NEXT:#define __clang_patchlevel__ {{.*}}
20792080
// WEBASSEMBLY-NEXT:#define __clang_version__ "{{.*}}"
20802081
// WEBASSEMBLY-NEXT:#define __clang_wide_literal_encoding__ {{.*}}
2082+
// WEBASSEMBLY-NEXT:#define __dpcpp_major__ 7
2083+
// WEBASSEMBLY-NEXT:#define __dpcpp_minor__ 0
2084+
// WEBASSEMBLY-NEXT:#define __dpcpp_patchlevel__ 0
20812085
// WEBASSEMBLY-NEXT:#define __llvm__ 1
20822086
// WEBASSEMBLY-WASI-NOT:#define __unix
20832087
// WEBASSEMBLY-WASI-NOT:#define __unix__

0 commit comments

Comments
 (0)