Skip to content

Commit 06c7c0d

Browse files
authored
Update for ocl-open-140 branch (#327)
1. Update version number and branch names 2. Enable Github Actions 3. Fix build errors Signed-off-by: Haonan Yang <[email protected]>
1 parent 81e96c3 commit 06c7c0d

File tree

6 files changed

+131
-34
lines changed

6 files changed

+131
-34
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: In-tree build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'ocl-open-*'
7+
paths-ignore: # no need to check build for:
8+
- 'docs/**' # documentation
9+
- '**.md' # README
10+
pull_request:
11+
branches:
12+
- 'ocl-open-*'
13+
paths-ignore: # no need to check build for:
14+
- 'docs/**' # documentation
15+
- '**.md' # README
16+
schedule:
17+
# Weekly build on Mondays
18+
# Ideally, we might want to simplify our regular nightly build as we
19+
# probably don't need every configuration to be built every day: most of
20+
# them are only necessary in pre-commits to avoid breakages
21+
- cron: 0 0 * * 0
22+
23+
env:
24+
LLVM_VERSION: 14
25+
26+
jobs:
27+
build_and_test_linux:
28+
name: Linux
29+
strategy:
30+
matrix:
31+
build_type: [Release]
32+
include:
33+
- build_type: Release
34+
fail-fast: false
35+
runs-on: ubuntu-18.04
36+
steps:
37+
- name: setup git config
38+
run: |
39+
git config --global user.email "<>"
40+
git config --global user.name "GitHub Actions Bot"
41+
- name: Checkout LLVM sources
42+
uses: actions/checkout@v2
43+
with:
44+
repository: llvm/llvm-project
45+
ref: release/14.x
46+
path: llvm-project
47+
- name: Checkout the translator sources
48+
uses: actions/checkout@v2
49+
with:
50+
repository: KhronosGroup/SPIRV-LLVM-Translator
51+
ref: llvm_release_140
52+
path: llvm-project/SPIRV-LLVM-Translator
53+
- name: Checkout opencl-clang sources
54+
uses: actions/checkout@v2
55+
with:
56+
path: llvm-project/opencl-clang
57+
- name: Configure
58+
run: |
59+
mkdir build && cd build
60+
cmake ${{ github.workspace }}/llvm-project/llvm \
61+
-DLLVM_ENABLE_PROJECTS="clang" \
62+
-DLLVM_EXTERNAL_PROJECTS="llvm-spirv;opencl-clang" \
63+
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=${{ github.workspace }}/llvm-project/SPIRV-LLVM-Translator \
64+
-DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=${{ github.workspace }}/llvm-project/opencl-clang \
65+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
66+
-DLLVM_TARGETS_TO_BUILD="X86" \
67+
-G "Unix Makefiles"
68+
- name: Build
69+
run: |
70+
cd build
71+
make opencl-clang -j2

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2020
add_definitions(-DUSE_PREBUILT_LLVM)
2121

2222
if(NOT PREFERRED_LLVM_VERSION)
23-
set(PREFERRED_LLVM_VERSION "13.0.0")
23+
set(PREFERRED_LLVM_VERSION "14.0.0")
2424
endif(NOT PREFERRED_LLVM_VERSION)
2525
message(STATUS "[OPENCL-CLANG] Looking for LLVM version ${PREFERRED_LLVM_VERSION}")
2626
find_package(LLVM ${PREFERRED_LLVM_VERSION} REQUIRED)
@@ -80,13 +80,13 @@ set(TARGET_NAME ${COMMON_CLANG_LIBRARY_NAME}${BUILD_PLATFORM} )
8080
if(NOT USE_PREBUILT_LLVM)
8181

8282
if(NOT LLVM_EXTERNAL_CLANG_SOURCE_DIR)
83-
set(LLVM_BASE_REVISION release_13)
83+
set(LLVM_BASE_REVISION release_14)
8484
set(CLANG_SOURCE_DIR ${LLVM_SOURCE_DIR}/tools/clang)
85-
set(CLANG_BASE_REVISION release_13)
85+
set(CLANG_BASE_REVISION release_14)
8686
elseif(EXISTS "${LLVM_EXTERNAL_CLANG_SOURCE_DIR}/CMakeLists.txt")
87-
set(LLVM_BASE_REVISION release/13.x)
87+
set(LLVM_BASE_REVISION release/14.x)
8888
set(CLANG_SOURCE_DIR "${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
89-
set(CLANG_BASE_REVISION release/13.x)
89+
set(CLANG_BASE_REVISION release/14.x)
9090
endif()
9191
if(EXISTS ${CLANG_SOURCE_DIR})
9292
message(STATUS "[OPENCL-CLANG] Using Clang source code direcotry: ${CLANG_SOURCE_DIR}")
@@ -121,8 +121,8 @@ if(NOT USE_PREBUILT_LLVM)
121121
)
122122
endif()
123123

124-
set(SPIRV_BASE_REVISION llvm_release_130)
125-
set(TARGET_BRANCH "ocl-open-130")
124+
set(SPIRV_BASE_REVISION llvm_release_140)
125+
set(TARGET_BRANCH "ocl-open-140")
126126
get_filename_component(LLVM_MONOREPO_DIR ${LLVM_SOURCE_DIR} DIRECTORY)
127127
set(LLVM_PATCHES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/patches/llvm
128128
${CMAKE_CURRENT_SOURCE_DIR}/patches/clang)

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![Build Status](https://travis-ci.com/intel/opencl-clang.svg?branch=master)](https://travis-ci.com/intel/opencl-clang)
2-
31
opencl-clang is a thin wrapper library around clang. The library has
42
OpenCL-oriented API and is capable to compile OpenCL C kernels to SPIR-V
53
modules.
@@ -25,9 +23,9 @@ Before the build all dependencies must be downloaded and laid out as follows:
2523
This can be done using the following commands:
2624
```bash
2725
cd <workspace>
28-
git clone https://github.com/llvm/llvm-project.git . -b release/13.x
29-
git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git -b llvm_release_130
30-
git clone https://github.com/intel/opencl-clang.git -b ocl-open-130
26+
git clone https://github.com/llvm/llvm-project.git . -b release/14.x
27+
git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git -b llvm_release_140
28+
git clone https://github.com/intel/opencl-clang.git -b ocl-open-140
3129
```
3230

3331
Then we need to create a build directory and run the build:
@@ -58,7 +56,7 @@ documented in [Embedding LLVM in your project](https://llvm.org/docs/CMake.html#
5856
Commands to checkout sources and build:
5957
```bash
6058
cd <workspace>
61-
git clone https://github.com/intel/opencl-clang.git -b ocl-open-130
59+
git clone https://github.com/intel/opencl-clang.git -b ocl-open-140
6260
mkdir build && cd build
6361
cmake ../opencl-clang
6462
make all -j`nproc`
@@ -68,7 +66,7 @@ make all -j`nproc`
6866

6967
##### Preferred LLVM version
7068

71-
By default, opencl-clang's cmake script is searching for LLVM 13.0.0. You can
69+
By default, opencl-clang's cmake script is searching for LLVM 14.0.0. You can
7270
override target version of LLVM by using the `PREFERRED_LLVM_VERSION` cmake
7371
option:
7472

cmake/modules/CMakeFunctions.cmake

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ endfunction()
8989
# Then all patches from the `patches_dir` are committed to the `target_branch`.
9090
# Does nothing if the `target_branch` is already checked out in the `repo_dir`.
9191
#
92-
function(apply_patches repo_dir patches_dir base_revision target_branch)
93-
file(GLOB patches ${patches_dir}/*.patch)
92+
function(apply_patches repo_dir patches_dir base_revision target_branch ret)
93+
foreach(patches_dir ${patches_dir})
94+
file(GLOB patches_in_dir ${patches_dir}/*.patch)
95+
list(APPEND patches ${patches_in_dir})
96+
endforeach()
9497
if(NOT patches)
9598
message(STATUS "[OPENCL-CLANG] No patches in ${patches_dir}")
9699
return()
@@ -105,7 +108,9 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
105108
ERROR_QUIET
106109
OUTPUT_QUIET
107110
)
108-
if(patches_needed) # The target branch doesn't exist
111+
if(patches_needed EQUAL 128) # not a git repo
112+
set(ret_not_git_repo 1)
113+
elseif(patches_needed) # The target branch doesn't exist
109114
list(SORT patches)
110115
is_valid_revision(${repo_dir} ${base_revision} exists_base_rev)
111116

@@ -139,8 +144,12 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
139144
WORKING_DIRECTORY ${repo_dir}
140145
OUTPUT_VARIABLE patching_log
141146
ERROR_QUIET
147+
RESULT_VARIABLE ret_apply_patch
142148
)
143149
message(STATUS "[OPENCL-CLANG] Not present - ${patching_log}")
150+
if (ret_apply_patch)
151+
break()
152+
endif()
144153
endif()
145154
endforeach(patch)
146155
else() # The target branch already exists
@@ -149,8 +158,14 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
149158
WORKING_DIRECTORY ${repo_dir}
150159
ERROR_QUIET
151160
OUTPUT_QUIET
161+
RESULT_VARIABLE ret_check_out
152162
)
153163
endif()
164+
if (NOT (ret_not_git_repo OR ret_check_out OR ret_apply_patch))
165+
set(${ret} True PARENT_SCOPE)
166+
else()
167+
message(FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!")
168+
endif()
154169
endfunction()
155170

156171
# Usage

options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ OpenCLArgList *OpenCLOptTable::ParseArgs(const char *szOptions,
8989
}
9090

9191
unsigned prev = index;
92-
Arg *pArg = ParseOneArg(*pArgs, index);
92+
std::unique_ptr<Arg> pArg = ParseOneArg(*pArgs, index);
9393
assert(index > prev && "Parser failed to consume argument.");
9494

9595
// Check for missing argument error.
@@ -101,8 +101,8 @@ OpenCLArgList *OpenCLOptTable::ParseArgs(const char *szOptions,
101101
break;
102102
}
103103

104-
m_synthesizedArgs.emplace_back(std::unique_ptr<llvm::opt::Arg>(pArg));
105-
pArgs->append(pArg);
104+
pArgs->append(pArg.get());
105+
m_synthesizedArgs.emplace_back(std::move(pArg));
106106
}
107107
return pArgs.release();
108108
}
Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
From 8b8ef4b0b24c12d3ab645acabd3cee58bff6ebc9 Mon Sep 17 00:00:00 2001
2-
From: haonanya <[email protected]>
3-
Date: Sat, 8 May 2021 15:18:02 +0800
4-
Subject: [PATCH] Remove __IMAGE_SUPPORT__ macro for SPIR since SPIR doesn't
5-
require image support
1+
From 1ca45b5f5725a447ded14c0096df39f2751c4e9a Mon Sep 17 00:00:00 2001
2+
From: Haonan Yang <[email protected]>
3+
Date: Fri, 25 Feb 2022 10:36:57 +0800
4+
Subject: [PATCH] Remove __IMAGE_SUPPORT__ macro for SPIR
65

7-
Signed-off-by: haonanya <[email protected]>
6+
Signed-off-by: Haonan Yang <[email protected]>
87
---
98
clang/lib/Frontend/InitPreprocessor.cpp | 3 ---
10-
clang/test/Preprocessor/predefined-macros.c | 2 --
11-
2 files changed, 5 deletions(-)
9+
clang/test/Preprocessor/predefined-macros.c | 4 ----
10+
2 files changed, 7 deletions(-)
1211

1312
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
14-
index 41b08ed56134..4e6fc0321b0e 100644
13+
index e259ab47c558..0bfdd62f17a2 100644
1514
--- a/clang/lib/Frontend/InitPreprocessor.cpp
1615
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
17-
@@ -1161,9 +1161,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
16+
@@ -1234,9 +1234,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
1817
// OpenCL definitions.
1918
if (LangOpts.OpenCL) {
2019
InitializeOpenCLFeatureTestMacros(TI, LangOpts, Builder);
2120
-
22-
- if (TI.getTriple().isSPIR())
21+
- if (TI.getTriple().isSPIR() || TI.getTriple().isSPIRV())
2322
- Builder.defineMacro("__IMAGE_SUPPORT__");
2423
}
2524

2625
if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) {
2726
diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c
28-
index e406b9a70570..88606518c7de 100644
27+
index 0b67cbe233ca..aad4a6f05563 100644
2928
--- a/clang/test/Preprocessor/predefined-macros.c
3029
+++ b/clang/test/Preprocessor/predefined-macros.c
31-
@@ -188,14 +188,12 @@
30+
@@ -207,28 +207,24 @@
3231

3332
// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
3433
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
@@ -43,6 +42,20 @@ index e406b9a70570..88606518c7de 100644
4342
// CHECK-SPIR64-DAG: #define __SPIR__ 1
4443
// CHECK-SPIR64-DAG: #define __SPIR64__ 1
4544
// CHECK-SPIR64-NOT: #define __SPIR32__ 1
45+
46+
// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spirv32-unknown-unknown \
47+
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIRV32
48+
-// CHECK-SPIRV32-DAG: #define __IMAGE_SUPPORT__ 1
49+
// CHECK-SPIRV32-DAG: #define __SPIRV__ 1
50+
// CHECK-SPIRV32-DAG: #define __SPIRV32__ 1
51+
// CHECK-SPIRV32-NOT: #define __SPIRV64__ 1
52+
53+
// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spirv64-unknown-unknown \
54+
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIRV64
55+
-// CHECK-SPIRV64-DAG: #define __IMAGE_SUPPORT__ 1
56+
// CHECK-SPIRV64-DAG: #define __SPIRV__ 1
57+
// CHECK-SPIRV64-DAG: #define __SPIRV64__ 1
58+
// CHECK-SPIRV64-NOT: #define __SPIRV32__ 1
4659
--
47-
2.17.1
60+
2.29.2
4861

0 commit comments

Comments
 (0)