RE: [PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-29 Thread Liu, Yaxun (Sam) via cfe-commits
Fixed by 361905.

Sam

-Original Message-
From: Petr Hosek via Phabricator  
Sent: Tuesday, May 28, 2019 9:54 PM
To: Liu, Yaxun (Sam) ; t...@google.com
Cc: pho...@google.com; cfe-commits@lists.llvm.org; mlek...@skidmore.edu; 
blitzrak...@gmail.com; shen...@google.com; jle...@google.com; 
zjturner0...@gmail.com
Subject: [PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

[CAUTION: External Email]

phosek added a comment.

This seems to be failing on macOS bots with the following error:

  FAIL: Clang :: CodeGenCUDA/dependent-libs.cu (3052 of 14933)
   TEST 'Clang :: CodeGenCUDA/dependent-libs.cu' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -fcuda-is-device -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=DEV 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  : 'RUN: at line 2';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=HOST 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  --
  Exit Code: 1

  Command Output (stderr):
  --
  /b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu:5:10: 
error: HOST: expected string not found in input
  // HOST: llvm.dependent-libraries
   ^
  :1:1: note: scanning from here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
  ^
  :1:58: note: possible intended match here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
   ^

  --

The full test log is here: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8912171419117598448/+/steps/clang/0/steps/test/0/stdout


Repository:
  rC Clang

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

https://reviews.llvm.org/D62483



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


[PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This seems to be failing on macOS bots with the following error:

  FAIL: Clang :: CodeGenCUDA/dependent-libs.cu (3052 of 14933)
   TEST 'Clang :: CodeGenCUDA/dependent-libs.cu' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -fcuda-is-device -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=DEV 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  : 'RUN: at line 2';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=HOST 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu:5:10: 
error: HOST: expected string not found in input
  // HOST: llvm.dependent-libraries
   ^
  :1:1: note: scanning from here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
  ^
  :1:58: note: possible intended match here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
   ^
  
  --

The full test log is here: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8912171419117598448/+/steps/clang/0/steps/test/0/stdout


Repository:
  rC Clang

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

https://reviews.llvm.org/D62483



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


[PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-28 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361880: [CUDA][HIP] Emit dependent libs for host only 
(authored by yaxunl, committed by ).
Herald added a project: clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D62483

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/dependent-libs.cu


Index: test/CodeGenCUDA/dependent-libs.cu
===
--- test/CodeGenCUDA/dependent-libs.cu
+++ test/CodeGenCUDA/dependent-libs.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck 
--check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -457,7 +457,12 @@
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = 
getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);


Index: test/CodeGenCUDA/dependent-libs.cu
===
--- test/CodeGenCUDA/dependent-libs.cu
+++ test/CodeGenCUDA/dependent-libs.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck --check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -457,7 +457,12 @@
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.

Recently D60274  was introduced to allow lld 
to handle dependent libs. However current
usage of dependent libs (e.g. pragma comment(lib, *)  in windows header files) 
are intended
for host only. Emitting the metadata in device IR causes link error in device 
path.

Until there is a way to different it dependent libs for device or host, 
metadata for dependent
libs should be emitted for host only. This patch enforces that.


https://reviews.llvm.org/D62483

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/dependent-libs.cu


Index: test/CodeGenCUDA/dependent-libs.cu
===
--- /dev/null
+++ test/CodeGenCUDA/dependent-libs.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck 
--check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -460,7 +460,12 @@
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = 
getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);


Index: test/CodeGenCUDA/dependent-libs.cu
===
--- /dev/null
+++ test/CodeGenCUDA/dependent-libs.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck --check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s
+
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libabc")
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -460,7 +460,12 @@
   // that ELF linkers tend to handle libraries in a more complicated fashion
   // than on other platforms. This forces us to defer handling the dependent
   // libs to the linker.
-  if (!ELFDependentLibraries.empty()) {
+  //
+  // CUDA/HIP device and host libraries are different. Currently there is no
+  // way to differentiate dependent libraries for host or device. Existing
+  // usage of #pragma comment(lib, *) is intended for host libraries on
+  // Windows. Therefore emit llvm.dependent-libraries only for host.
+  if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) {
 auto *NMD = getModule().getOrInsertNamedMetadata("llvm.dependent-libraries");
 for (auto *MD : ELFDependentLibraries)
   NMD->addOperand(MD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits