[PATCH] D79788: AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

2020-05-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

235fb7dc24b1cf7034dfc76bb853ffb4ac5dec5d 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79788/new/

https://reviews.llvm.org/D79788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79788: AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

2020-05-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79788/new/

https://reviews.llvm.org/D79788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79788: AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

2020-05-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, Anastasia, svenvh.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

-nogpulib makes sense when there is a host (where -nostdlib would
apply) and offload target. Accept nostdlib when there is no offload
target as an alias.


https://reviews.llvm.org/D79788

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/rocm-detect.hip
  clang/test/Driver/rocm-not-found.cl


Index: clang/test/Driver/rocm-not-found.cl
===
--- clang/test/Driver/rocm-not-found.cl
+++ clang/test/Driver/rocm-not-found.cl
@@ -7,5 +7,7 @@
 // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 
2>&1 | FileCheck %s --check-prefix ERR
 // ERR: cannot find ROCm installation. Provide its path via --rocm-path, or 
pass -nogpulib.
 
+// Accept nogpulib or nostdlib for OpenCL.
 // RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck 
%s --check-prefix OK
+// RUN: %clang -### -nostdlib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck 
%s --check-prefix OK
 // OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-detect.hip
===
--- /dev/null
+++ clang/test/Driver/rocm-detect.hip
@@ -0,0 +1,27 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Make sure the appropriate device specific library is available.
+
+// We don't include every target in the test directory, so just pick a valid
+// target not included in the test.
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+// Should not interpret -nostdlib as disabling offload libraries.
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 
-nostdlib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 
-nogpulib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902,NODEFAULTLIBS %s
+
+
+// GFX902-DEFAULTLIBS: error: cannot find device library for gfx902. Provide 
path to different ROCm installation via --rocm-path, or pass -nogpulib to build 
without linking default libraries.
+
+// NODEFAULTLIBS-NOT: error: cannot find
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -361,6 +361,12 @@
   AMDGPUToolChain::addClangTargetOptions(DriverArgs, CC1Args,
  DeviceOffloadingKind);
 
+  // For the OpenCL case where there is no offload target, accept -nostdlib to
+  // disable bitcode linking.
+  if (DeviceOffloadingKind == Action::OFK_None &&
+  DriverArgs.hasArg(options::OPT_nostdlib))
+return;
+
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 


Index: clang/test/Driver/rocm-not-found.cl
===
--- clang/test/Driver/rocm-not-found.cl
+++ clang/test/Driver/rocm-not-found.cl
@@ -7,5 +7,7 @@
 // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
 // ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
 
+// Accept nogpulib or nostdlib for OpenCL.
 // RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// RUN: %clang -### -nostdlib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
 // OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-detect.hip
===
--- /dev/null
+++ clang/test/Driver/rocm-detect.hip
@@ -0,0 +1,27 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Make sure the appropriate device specific library is available.
+
+// We don't include every target in the test directory, so just pick a valid
+// target not included in the test.
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+// Should not interpret -nostdlib as disabling offload libraries.
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nostdlib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902