0

I am building my application using OpenMPI (built with LLVM) and few other external libraries including netcdf-fortran, BLAS and LAPACK. The files compile without any problem, but in the last stage where all the object files are being linked I get the following error

ld.lld: error: undefined symbol: _rad_8_
>>> referenced by buildings_rad_walls.f90:26 (/home/rangke/archive/gsam1.4/SRC/BUILDINGS/buildings_rad_walls.f90:26)
>>>               buildings_rad_walls.o:(buildings_rad_walls_)
>>> referenced by buildings_rad_walls.f90:0 (/home/rangke/archive/gsam1.4/SRC/BUILDINGS/buildings_rad_walls.f90:0)
>>>               buildings_rad_walls.o:(buildings_rad_walls_)
>>> referenced by buildings_rad_walls.f90:0 (/home/rangke/archive/gsam1.4/SRC/BUILDINGS/buildings_rad_walls.f90:0)
>>>               buildings_rad_walls.o:(buildings_rad_walls_)
>>> referenced 69 more times
>>> did you mean: _rad_0_
>>> defined in: rad.o
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

The error message indicates that lines of 0 and 26 in /home/rangke/archive/gsam1.4/SRC/BUILDINGS/buildings_rad_walls.f90 references _rad8_, but this file does not contain nor any of my files contain a variable named _rad_8_. Line 0 in the file is a comment, and the line 26 contains the following

if(doshadows.and.flag_sunny) then

which has nothing to do with the _rad_8_. doshadows and flag_sunny are logical data type, not an integer or real or double data type.

The following is the linking part of my makefile content.

LD = mpifort
LDFLAGS = -${ncf_dir}/lib -lnetcdff -lblas -llapack
...
...
...
$(LD) -o $@ $(OBJS) $(LDFLAGS)

where ${ncf_dir} is the netcdf-fortran directory.

I am suspecting that the variable _rad_8_ has to do with BLAS or LAPACK, specifically something with data type precision. I have tried different BLAS and LAPACK library, such as BLIS and libflame, but to no avail. Does anyone have any idea what is happening here? Any idea would help.

More clues.

What I have found out is that when I put -fdefault-real-8 flag so that every real is treated as 8 byte, I get the following error message

mpifort -c -O3 -Mpreprocess -Mextend -mcmodel=large -march=znver2 -r8 -I/usr/include /home/rangke/archive/gsam1.4/SRC/zero.f90
/tmp/rad-9b513e.ll:36:1: error: invalid use of function-local name
%struct_rad_8_ = type < { [4 x i8]  } > 
^
1 error generated.
make: *** [/home/rangke/archive/gsam1.4/makefile:62: rad.o] Error 1
make: *** Waiting for unfinished jobs....

This error mesage contains the _rad_8_ in question, but I am not sure where it is from. It seems like this error message is for the /home/rangke/archive/gsam1.4/SRC/zero.f90, but according to the make output it is produced during the compilation of rad.o which is different file.

Where is this

%struct_rad_8_ = type < { [4 x i8]  } >

from? I can confidently say that it is not part of my application, it is not in /home/rangke/archive/gsam1.4/SRC/zero.f90 or in the rad.f90 file.

More more clues

I found that _rad_8_ comes from LLVM IR (bit code). I have compiled the same code on AMD 4750U and AMD EPYC 7513, and they produce different LLVM IR codes. In short EPYC 7513 produces %struct_rad_8_ = type < { [4 x i8] } >, and eventually leads to successful linking process of my application, while AMD 4750U does not. Why is this happening? Is this problem inherent to the AMD CPU generations? Or is there a way to force AMD 4750U to gerenate the %struct_rad_8_ = type < { [4 x i8] } > part? I have listed the detailed LLVM IR issue in the AMD forum : https://community.amd.com/t5/processors/different-llvm-ir-content-for-the-same-code-on-different-zen/td-p/610733

11
  • I could not find any rad_8_ symbol in the LLVM runtime so this is pretty suspicious. make sure you use implicit none everywhere to make sure the compiler can spot this kind of typo. Commented Jun 4, 2023 at 2:40
  • Yeah. I did make sure to add implicit none on every file. Though, I am getting the same error. I am trying to gernerate some more detailed debug message. -g flag does not seem to work at all. Any suggestions? Commented Jun 4, 2023 at 3:57
  • what does line 26 of /home/rangke/archive/gsam1.4/SRC/BUILDINGS/buildings_rad_walls.f90 contains? just in case, try removing the object file and run make again in order to make sure the file is needed and was rebuilt. Commented Jun 4, 2023 at 4:35
  • In some configurations, you would need to -lnetcdff -lnetcdf and link with lapack first -llapack -lblas. this is very likely unrelated to this issue though. Commented Jun 4, 2023 at 4:38
  • The content of the line 26 is shown in the main question. It is just a if statement with two logical data types. Commented Jun 4, 2023 at 4:39

1 Answer 1

0

I figure it out. As it turns out, I did not assign enough MPI process numbers for the memory work out. So, it did not have to with CPU architecture or linker.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.