Skip to content

Commit

Permalink
Pass -offload-lto instead of -lto for cuda/hip kernels and enable fai…
Browse files Browse the repository at this point in the history
…led tests
  • Loading branch information
omarahmed1111 committed Jan 13, 2025
1 parent 1a7e2f0 commit 6c7fbf7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion clang/test/Driver/linker-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ __attribute__((visibility("protected"), used)) int x;
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK

// NVPTX-LINK: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 -flto {{.*}}.o {{.*}}.o
// NVPTX-LINK: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 -O2 -foffload-lto {{.*}}.o {{.*}}.o

// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
Expand Down
7 changes: 6 additions & 1 deletion clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,6 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
};

// Forward all of the `--offload-opt` and similar options to the device.
CmdArgs.push_back("-flto");
for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
CmdArgs.append(
{"-Xlinker",
Expand All @@ -1542,6 +1541,12 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
if (!Triple.isNVPTX() && !Triple.isSPIRV())
CmdArgs.push_back("-Wl,--no-undefined");

if (Triple.isNVPTX() || Triple.isAMDGPU()) {
CmdArgs.push_back("-foffload-lto");
} else {
CmdArgs.push_back("-flto");
}

if (IsSYCLKind && Triple.isNVPTX())
CmdArgs.push_back("-S");
for (StringRef InputFile : InputFiles)
Expand Down
2 changes: 0 additions & 2 deletions sycl/test-e2e/NewOffloadDriver/multisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// XFAIL: cuda
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/16413
// Separate kernel sources and host code sources
// Test with `--offload-new-driver`
// RUN: %{build} --offload-new-driver -c -o %t.kernel.o -DINIT_KERNEL -DCALC_KERNEL
Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %{build} -Wno-error=unused-command-line-argument -fsycl-device-code-split=per_source -I %S/Inputs -o %t.out %S/Inputs/split-per-source-second-file.cpp \
// RUN: --offload-new-driver -fsycl-dead-args-optimization
// RUN: %{run} %t.out
//
// XFAIL: cuda
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/16413

#include "Inputs/split-per-source.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// RUN: %{build} -DSOURCE2 --offload-new-driver -c -o %t2.o
// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl -fsycl-targets=%{sycl_triple} --offload-new-driver %t1.o %t2.o -o %t.exe
// RUN: %{run} %t.exe
// XFAIL: cuda
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/16413

#ifdef SOURCE1
#include <iostream>
Expand Down

0 comments on commit 6c7fbf7

Please sign in to comment.