PGI 18.4 pgfortran error in LLVM when compiling with -g

Dear,

I’m getting an error in ‘llc’ for this code:

$ pgfortran --version

pgfortran 18.4-0 LLVM 64-bit target on x86-64 Linux -tp haswell 
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
$ cat >mini.f90 <<EOF
      subroutine foo(name)
      character(len=*) :: name
      end subroutine foo
EOF
$ pgfortran -c mini.f90
$ pgfortran -c -g mini.f90
/home/wesarg/opt/pgi-18.4/linux86-64-llvm/18.4/share/llvm/bin/llc: /tmp/pgfortrana0QhaGEqkC6Y.ll:45:7: error: expected metadata type
!23 = !DIStringType(name: "character(*)!1", size: 32, stringLength: !21, stringLengthExpression: !22)
      ^

I’m not getting the same results. What OS are you on?

$ pgfortran --version

pgfortran 18.4-0 LLVM 64-bit target on x86-64 Linux -tp haswell
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
$ cat mini.f90
subroutine foo(name)
character(len=*) :: name
end subroutine foo
$ pgfortran -c mini.f90
$ pgfortran -c -g mini.f90

Duh, I’m sorry, completely my fault. I replaced the shipped LLVM binaries (llc, llvm-mc, and opt) with those from an original LLVM binary package.

May I suggest, that the shipped LLVM binaries have a different vendor and version than the original LLVM binaries. Both provide currently the same, and thus don’t indicate that the PGI ones are improved:

$ /home/wesarg/opt/pgi-18.4/linux86-64-llvm/18.4/share/llvm/bin/llc -version
LLVM (http://llvm.org/):
  LLVM version 5.0.1
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake

  Registered Targets:
…
$ /home/wesarg/opt/llvm-5.0.1/bin/llc -version
LLVM (http://llvm.org/):
  LLVM version 5.0.1
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake

  Registered Targets:
…

LLVM already provide means for this:

$ cmake … -DPACKAGE_VENDOR='PGI/LLVM:\n ' -DLLVM_VERSION_SUFFIX=-pgi path/to/llvm/source

The ':\n ’ part in the PACKAGE_VENDOR string looks awkward, but is needed. Else you may want to upstream the following patch:

diff --git i/lib/Support/CommandLine.cpp w/lib/Support/CommandLine.cpp
index a1e659a01c8..6ca4048873f 100644 lib/Support/CommandLine.cpp
--- i/lib/Support/CommandLine.cpp
+++ w/lib/Support/CommandLine.cpp
@@ -2115,5 +2115,5 @@ public:
     raw_ostream &OS = outs();
 #ifdef PACKAGE_VENDOR
-    OS << PACKAGE_VENDOR << " ";
+    OS << PACKAGE_VENDOR << ":\n  ";
 #else
     OS << "LLVM (http://llvm.org/):\n  ";

Thanks, and sorry for the noise.

Btw, it looks like, it is also not a good idea to replace the provided CUDA parts with an original CUDA installation. At least the headers are from an original CUDA SDK are missing many defined(__PGI) checks.

Bert,

No problem. Thanks for the suggestion, I’ll pass it along to the engineers.

Hi Bert,

We went ahead and made the change to the version string. Should be reflected in 18.7:

$ llc -version
PGI LLVM:
LLVM version 6.0.1-pgi9