Open jjennychen opened 2 months ago
test1: # /usr/bin/ld: main.o:(.hipFatBinSegment+0x8): undefined reference to `__hip_fatbin'
/space/pvelesko/chipStar/fix-893/build/bin/cucc -dc main.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -c function.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc main.o function.o -o driver
test2: #/usr/bin/ld: function.o:(.hipFatBinSegment+0x8): undefined reference to `__hip_fatbin'
/space/pvelesko/chipStar/fix-893/build/bin/cucc -c main.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -dc function.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc main.o function.o -o driver
# InvalidInstruction: Can't translate llvm instruction:
# Global variable cannot have Function storage class. Consider setting a proper address space.
# Original LLVM value:
# @__clang_gpu_used_external = internal global [1 x ptr] [ptr @_Z4testv]
test3:
/space/pvelesko/chipStar/fix-893/build/bin/cucc -dc main.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -dc function.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -fgpu-rdc main.o function.o -o driver
#InvalidTargetTriple: Expects spir-unknown-unknown or spir64-unknown-unknown. Actual target triple is <BLANK?>
test4:
/space/pvelesko/chipStar/fix-893/build/bin/cucc -c main.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -c function.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -fgpu-rdc main.o function.o -o driver
# correct
test5:
/space/pvelesko/chipStar/fix-893/build/bin/cucc -c main.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -dc function.cu
/space/pvelesko/chipStar/fix-893/build/bin/cucc -fgpu-rdc main.o function.o -o driver
clean:
rm -f *.o driver
@jjennychen Can you please change the makefile as test5
for now as a workaround?
@pjaaskel @Kerilk
What do you propose we do here?
@pjaaskel @linehill ping
During the linking of object files that were compiled with
reallocatable_device_code
set to true,undefined reference to __hip_fatbin
error was produced.-rdc=true
(or--relocatable-device-code=true
) flag needs to be explicitly added during linking in order to link successfully, but CUDA's nvcc doesn't require it (it links successfully without the-rdc=true
flag). Please see the below reproducer for more details:[Reproducer] Have the following three files, main.cu, function.hpp, and function.cu:
main.cu
function.hpp
function.cu
Compile the main.cu and function.cu with the following commands (these should compile fine with the newly added -dc flag support):
nvcc -dc -o main.o main.cu
nvcc -dc -o function.o function.cu
Then, link the object files:
nvcc -o main main.o function.o
The following error should appear: