[clang] [llvm] [Driver][SYCL] Add initial SYCL offload compilation support (PR #107493)
Tom Honermann via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 08:44:08 PST 2024
================
@@ -0,0 +1,202 @@
+//===--- SYCL.cpp - SYCL Tool and ToolChain Implementations -----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "SYCL.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Action.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include <algorithm>
+#include <sstream>
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang::driver::tools;
+using namespace clang;
+using namespace llvm::opt;
+
+SYCLInstallationDetector::SYCLInstallationDetector(const Driver &D)
+ : D(D), InstallationCandidates() {
+ InstallationCandidates.emplace_back(D.Dir + "/..");
+}
+
+void SYCLInstallationDetector::AddSYCLIncludeArgs(
+ const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+ // Add the SYCL header search locations in the specified order.
+ // ../include/sycl
+ // ../include/sycl/stl_wrappers
+ // ../include
----------------
tahonermann wrote:
Sure, but this looks like it could result in `../include` being added to the command line multiple times. That can be problematic for relative include path orders and, specifically, for `#include_next`. I agree that support for `#include <sycl/sycl.hpp>` should be included, but I'm skeptical that potentially adding the same path multiple times is the right way to do that.
I think there are other issues here as well. `SYCLInstallationDetector` doesn't actually appear to do any detecting. Is the intention that future changes will add probing of installation candidates? Regardless, I think any additions to `CC1Args` should be conditional on an installation having been detected. As is, the `InstallationCandidates` member doesn't appear to serve any purpose.
https://github.com/llvm/llvm-project/pull/107493
More information about the llvm-commits
mailing list