Skip to content

Commit 5e5703f

Browse files
authored
[SYCL] Allow multiple build options for opencl-aot (#2828)
This patch adds handling of multiple build options if they were set separately. Covered by test from intel/llvm-test-suite#58. Signed-off-by: Viktoria Maksimova <[email protected]>
1 parent 56b9a1d commit 5e5703f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

opencl-aot/source/main.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ int main(int Argc, char *Argv[]) {
299299
"o", cl::init("output.bin"),
300300
cl::desc("Specify the output OpenCL program binary filename"),
301301
cl::value_desc("filename"));
302-
cl::opt<std::string> OptBuildOptions("bo",
303-
cl::desc("Set OpenCL build options"),
304-
cl::value_desc("build options"));
302+
cl::list<std::string> OptBuildOptions("bo", cl::ZeroOrMore,
303+
cl::desc("Set OpenCL build options"),
304+
cl::value_desc("build options"));
305305

306306
cl::ParseCommandLineOptions(Argc, Argv,
307307
"OpenCL ahead-of-time (AOT) compilation tool");
@@ -414,16 +414,21 @@ int main(int Argc, char *Argv[]) {
414414
CLProgramUPtr ProgramUPtr(std::move(Progs[0]));
415415

416416
// step 7: set OpenCL build options
417-
std::string BuildOptions = OptBuildOptions;
417+
std::string BuildOptions;
418+
if (!OptBuildOptions.empty()) {
419+
for (const auto &BO : OptBuildOptions)
420+
BuildOptions += BO + ' ';
421+
}
422+
418423
auto ParentDir = sys::path::parent_path(OptInputBinary);
419424
if (!ParentDir.empty()) {
420425
BuildOptions += " -I \"" + std::string(ParentDir) + '\"';
421426
}
422427
std::cout << "Using build options: " << BuildOptions << '\n';
423428

424429
// step 8: build OpenCL program
425-
CLErr = clBuildProgram(ProgramUPtr.get(), 1, &DeviceId,
426-
OptBuildOptions.c_str(), nullptr, nullptr);
430+
CLErr = clBuildProgram(ProgramUPtr.get(), 1, &DeviceId, BuildOptions.c_str(),
431+
nullptr, nullptr);
427432

428433
std::string CompilerBuildLog;
429434
std::tie(CompilerBuildLog, ErrorMessage, std::ignore) =

0 commit comments

Comments
 (0)