Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flang vs gfortran compiling same code with -flto flag flang runs into /usr/bin/ld: /usr/bin/../lib/LLVMgold.so: error loading plugin: /usr/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory #1193

Closed
iajzenszmi opened this issue Dec 15, 2021 · 2 comments

Comments

@iajzenszmi
Copy link

flang vs gfortran compiling same code with -flto flag flang runs into /usr/bin/ld: /usr/bin/../lib/LLVMgold.so: error loading plugin: /usr/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory

(base) ian@ian-Aspire-One-753:/CodeCode/CodeCode$ flang xspline.f -flto -o xspline
/usr/bin/ld: /usr/bin/../lib/LLVMgold.so: error loading plugin: /usr/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
flang-7: error: linker command failed with exit code 1 (use -v to see invocation)
(base) ian@ian-Aspire-One-753:
/CodeCode/CodeCode$ gfortran xspline.f -flto -o xspline
(base) ian@ian-Aspire-One-753:/CodeCode/CodeCode$ ./xspline
SECOND - DERIVATIVES FOR SIN(X) FROM 0 TO PI
SPLINE ACTUAL
ANGLE 2ND DERIV 2ND DERIV
0.16 -0.156832 -0.156434
0.31 -0.309631 -0.309017
0.47 -0.454933 -0.453991
0.63 -0.588991 -0.587785
0.79 -0.708561 -0.707107
0.94 -0.810683 -0.809017
1.10 -0.892844 -0.891007
1.26 -0.953009 -0.951057
1.41 -0.989721 -0.987688
1.57 -1.002061 -1.000000
1.73 -0.989715 -0.987688
1.88 -0.953020 -0.951056
2.04 -0.892835 -0.891006
2.20 -0.810685 -0.809017
2.36 -0.708558 -0.707107
2.51 -0.588999 -0.587785
2.67 -0.454920 -0.453990
2.83 -0.309660 -0.309017
2.98 -0.156736 -0.156434
3.14 -0.000075 0.000000
(base) ian@ian-Aspire-One-753:
/CodeCode/CodeCode$
(base) ian@ian-Aspire-One-753:/CodeCode/CodeCode$ cat xspline.f
PROGRAM XSPLINE
C PAGE 33 NUMERICAL RECIPIES EXAMPLE BOOK SECOND EDITION.
C DRIVER FOR ROUTINE SPLINE
INTEGER N
REAL PI
PARAMETER(N=20,PI=3.141593)
INTEGER I
REAL YPI, YPN, X(N),Y(N),Y2(N)
WRITE(,) 'SECOND - DERIVATIVES FOR SIN(X) FROM 0 TO PI'
C GENERATE ARRAY FOR INTERPOLATION
C
DO 11 I=1,20
X(I)=IPI/N
Y(I)=SIN(X(I))
11 CONTINUE
C
C CALCULATE 2ND DERIVATIVE WITH SPLINE
C
YP1=COS(X(1))
YPN=COS(X(N))
CALL SPLINE(X,Y,N,YP1,YPN,Y2)
C TEST RESULT
WRITE(
,'(T19,A,T35,A)') 'SPLINE','ACTUAL'
WRITE(,'(T6,A,T17,A,T33,A)') 'ANGLE','2ND DERIV','2ND DERIV'
DO 12 I = 1, N
WRITE(
,'(1X,F8.2,2F16.6)') X(I),Y2(I),-SIN(X(I))
12 CONTINUE
END PROGRAM
SUBROUTINE SPLINE(X,Y,N,YP1,YPN,Y2)
PARAMETER (NMAX=100)
DIMENSION X(N),Y(N),Y2(N),U(NMAX)
IF (YP1.GT..99E30) THEN
Y2(1)=0.0
U(1)=0.0
ELSE
Y2(1)=-0.5
U(1)=(3./(X(2)-X(1)))((Y(2)-Y(1))/(X(2)-X(1))-YP1)
ENDIF
DO 11 I=2,N-1
SIG=(X(I)-X(I-1))/(X(I+1)-X(I-1))
P=SIG
Y2(I-1)+2.
Y2(I)=(SIG-1.)/P
U(I) = (6.((Y(I+1)-Y(I))/(X(I+1)-X(I))-(Y(I)-Y(I-1))
* /(X(I)-X(I-1)))/(X(I+1)-X(I-1))-SIG
U(I-1))/P
11 CONTINUE
IF (YPN.GT..99E30) THEN
QN=0.
UN=0.
ELSE
QN=0.5
UN=(3./(X(N)-X(N-1)))(YPN-(Y(n)-Y(N-1))/(X(N)-X(N-1)))
ENDIF
Y2(N)=(UN-QN
U(N-1))/(QN*Y2(N-1)+1.)
DO 12 K=N-1,1,-1
Y2(K)=Y2(K)*Y2(K+1)+U(K)
12 CONTINUE
RETURN
END SUBROUTINE
(base) ian@ian-Aspire-One-753:
/CodeCode/CodeCode$

@bryanpkc
Copy link
Collaborator

You need to make sure that the LLVM build can generate LLVMgold.so. If I remember correctly, you need to make sure that binutils headers (specifically plugin-api.h) can be found on the system; on Ubuntu that would require running apt install binutils-dev. You might need to point LLVM's CMake files at the location of the header with the variable LLVM_BINUTILS_INCDIR. Finally, you should probably also enable building lld when configuring LLVM, by adding lld to LLVM_ENABLE_PROJECTS when running CMake.

@pawosm-arm
Copy link
Collaborator

This isn't actual issue. LTO works fine with classic flang, we're using it a lot with no trouble, so I'm closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants