[clang] [Offload] Handle `BoundArchitecture` for non-GPU targets (PR #132037)
Nick Sarnie via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 19 08:57:19 PDT 2025
================
@@ -3388,46 +3388,44 @@ Generic_GCC::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
}
llvm::opt::DerivedArgList *
-Generic_GCC::TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef,
+Generic_GCC::TranslateArgs(const llvm::opt::DerivedArgList &Args,
+ StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) const {
+ if (DeviceOffloadKind != Action::OFK_SYCL &&
+ DeviceOffloadKind != Action::OFK_OpenMP)
+ return nullptr;
- // If this tool chain is used for an OpenMP offloading device we have to make
- // sure we always generate a shared library regardless of the commands the
- // user passed to the host. This is required because the runtime library
- // is required to load the device image dynamically at run time.
+ DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
+
+ // Filter all the arguments we don't care passing to the offloading
+ // toolchain as they can mess up with the creation of a shared library.
+ const llvm::DenseSet<unsigned> OpenMPFiltered{
+ options::OPT_shared, options::OPT_dynamic, options::OPT_static,
+ options::OPT_fPIE, options::OPT_fno_PIE, options::OPT_fpie,
+ options::OPT_fno_pie};
+ for (auto *A : Args)
+ if (DeviceOffloadKind != Action::OFK_OpenMP ||
+ !OpenMPFiltered.contains(A->getOption().getID()))
+ DAL->append(A);
+
+ // Request the shared library for CPU offloading. Given that these options
----------------
sarnex wrote:
grammar nit
```suggestion
// Request a shared library for CPU offloading. Given that these options
```
https://github.com/llvm/llvm-project/pull/132037
More information about the cfe-commits
mailing list