Skip to content

Commit 51f3828

Browse files
Another attempt at CMake
1 parent 7ef5c4a commit 51f3828

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

sycl-jit/jit-compiler/CMakeLists.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
get_host_tool_path( clang CLANG clang_exe clang_target )
22

33
set(SYCL_JIT_RESOURCE_CPP "${CMAKE_CURRENT_BINARY_DIR}/resource.cpp")
4-
# NOTE: has to have a name different from the "default" object target:
5-
set(SYCL_JIT_RESOURCE_OBJ "${CMAKE_CURRENT_BINARY_DIR}/resource.cpp.custom.o")
4+
set(SYCL_JIT_RESOURCE_OBJ "${CMAKE_CURRENT_BINARY_DIR}/resource.cpp.o")
65

76
add_custom_command(
87
OUTPUT ${SYCL_JIT_RESOURCE_CPP}
@@ -16,10 +15,22 @@ add_custom_command(
1615
# We use C23/C++26's `#embed` to implement this resource creation, and "current"
1716
# CMAKE_CXX_COMPILER might not have support for it. As such, use freshly built
1817
# `clang++` instead.
18+
set(SYCL_JIT_RESOURCE_CXX_FLAGS -O2 -Wno-c23-extensions)
19+
if (LLVM_ENABLE_PIC)
20+
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS -fPIC)
21+
endif()
22+
23+
if (NOT WIN32)
24+
list(APPEND SYCL_JIT_RESOURCE_CXX_FLAGS -fvisibility=hidden)
25+
endif()
26+
1927
add_custom_command(
2028
OUTPUT ${SYCL_JIT_RESOURCE_OBJ}
21-
COMMAND ${clang_exe} ${SYCL_JIT_RESOURCE_CPP} -c -o ${SYCL_JIT_RESOURCE_OBJ} -O2 -Wno-c23-extensions -fPIC
22-
DEPENDS ${SYCL_JIT_RESOURCE_CPP}
29+
COMMAND
30+
${clang_exe} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS}
31+
DEPENDS
32+
${SYCL_JIT_RESOURCE_CPP}
33+
${CMAKE_CURRENT_SOURCE_DIR}/include/Resource.h
2334
)
2435

2536
add_llvm_library(sycl-jit
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#pragma once
10+
11+
#include <string_view>
12+
#include <utility>
13+
14+
namespace jit_compiler {
15+
// Defined in the auto-generated file:
16+
extern const std::pair<std::string_view, std::string_view> ToolchainFiles[];
17+
extern size_t NumToolchainFiles;
18+
extern std::string_view ToolchainPrefix;
19+
} // namespace jit_compiler

sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DeviceCompilation.h"
1010
#include "ESIMD.h"
1111
#include "JITBinaryInfo.h"
12+
#include "Resource.h"
1213
#include "translation/Translation.h"
1314

1415
#include <clang/Basic/DiagnosticDriver.h>
@@ -51,13 +52,6 @@
5152
#include <array>
5253
#include <sstream>
5354

54-
namespace jit_compiler {
55-
// Defined in the auto-generated file:
56-
extern const std::pair<std::string_view, std::string_view> ToolchainFiles[];
57-
extern size_t NumToolchainFiles;
58-
extern std::string_view ToolchainPrefix;
59-
} // namespace jit_compiler
60-
6155
using namespace clang;
6256
using namespace clang::tooling;
6357
using namespace clang::driver;

sycl-jit/jit-compiler/utils/generate.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ def main():
2525
with open(args.output, "w") as out:
2626
out.write(
2727
"""
28-
#include <utility>
29-
#include <string_view>
28+
#include <Resource.h>
3029
3130
namespace jit_compiler {
32-
extern const std::pair<std::string_view, std::string_view> ToolchainFiles[];
3331
const std::pair<std::string_view, std::string_view> ToolchainFiles[] = {"""
3432
)
3533

@@ -57,9 +55,7 @@ def process_dir(dir):
5755
f"""
5856
}};
5957
60-
extern size_t NumToolchainFiles;
6158
size_t NumToolchainFiles = std::size(ToolchainFiles);
62-
extern std::string_view ToolchainPrefix;
6359
std::string_view ToolchainPrefix = "{args.prefix}";
6460
}} // namespace jit_compiler
6561
"""

0 commit comments

Comments
 (0)