Hello Ileana It seems your original patch is good, provided I add
autoreconf -fiv -Wall or similar. My problem was in building netcdf. However, on closer inspection, I noticed that the patched libtool was not picked up, for some reason: 40 # Which release of libtool.m4 was used? 41 macro_version=2.4.7 42 macro_revision=2.4.7 However, adding the "autoreconf" step seems to have fixed that: 39 # Which release of libtool.m4 was used? 40 macro_version=2.5.0.21-cc511 41 macro_revision=2.5.0.21 Many thanks Anton > On 29 Jun 2024, at 12:46, Ileana Dumitrescu <ileanadumitresc...@gmail.com> > wrote: > > On 28/06/2024 08:56, Shterenlikht, Anton wrote: >>> On 27 Jun 2024, at 17:36, Ileana Dumitrescu <ileanadumitresc...@gmail.com> >>> wrote: >>> >>> On 26/06/2024 10:21, Shterenlikht, Anton wrote: >>>> Please help understand and fix this problem: >>>> libtool: link: ftn -shared <skip files> -soname libxxx.so.0 -o >>>> .libs/libxxx.so.0.0.0 >>>> clang-16: error: unknown argument: '-soname' >>>> which comes from my compiler wrapper not recognised. >>> >>> Sorry for missing your earlier response. To set 'wl' for >>> flang, armflang, flang-new, and ftn, the following patch >>> should work: >>> >>> --- a/m4/libtool.m4 >>> +++ b/m4/libtool.m4 >>> @@@ -4805,7 -4805,7 +4805,7 @@@ m4_if([$1], [CXX], >>> _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' >>> _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' >>> ;; >>> -- *flang) >>> ++ *flang* | ftn*) >>> # Flang compiler. >>> _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' >>> _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' >>> >>> Could you test this again in your environment? >> That's what I tried before, but it does not help. >> If I clone with: git clone https://git.savannah.gnu.org/git/libtool.git >> I get different line numbers: >> % git diff >> diff --git a/m4/libtool.m4 b/m4/libtool.m4 >> index bbf2d21f..8ec0be58 100644 >> --- a/m4/libtool.m4 >> +++ b/m4/libtool.m4 >> @@ -4706,7 +4706,7 @@ m4_if([$1], [CXX], [ >> _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' >> _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' >> ;; >> - *flang) >> + *flang* | ftn) >> # Flang compiler. >> _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' >> _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' >> Am I on the right branch? > > I usually am working off of development instead of master. > >> With that patch I get in share/aclocal/libtool.m4 >> 4701 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) >> 4702 case $cc_basename in >> 4703 # old Intel for x86_64, which still supported -KPIC. >> 4704 ecc*) >> 4705 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' >> 4706 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' >> 4707 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' >> 4708 ;; >> 4709 *flang* | ftn) >> 4710 # Flang compiler. >> 4711 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' >> 4712 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' >> 4713 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' >> 4714 ;; >> However, this does not help. >> I still get in my project libtool: >> # A language specific compiler. >> CC="ftn" >> # Is the compiler the GNU compiler? >> with_gcc=no >> # Compiler flag to turn off builtin functions. >> no_builtin_flag="" >> # Additional compiler flags for building library objects. >> pic_flag="" >> # How to pass a linker flag through the compiler. >> wl="" >> I wonder if flang/ftn is applied in the right place in m4/libtool.m4. >> Or maybe has to be applied in several places. > > I also think it may need to be applied multiple places, but I am not > confident on where to put it. > >> Other compilers appear multiple times, e.g. nagfor: >> % grep -nC1 icc m4/libtool.m4 >> 4714- ;; >> 4715: # icc used to be incompatible with GCC. >> 4716- # ICC 10 doesn't accept -KPIC any more. >> 4717: icc* | ifort*) >> 4718- _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' >> -- >> 5217- tmp_addflag=' $pic_flag -Mnomain' ;; >> 5218: ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 >> 5219- tmp_addflag=' -i_dynamic' ;; >> ashterenli@NB-068 libtool % grep -nC1 nagfor m4/libtool.m4 >> 1117- case $cc_basename in >> 1118: ifort*|nagfor*) _lt_dar_can_shared=yes ;; >> 1119- *) _lt_dar_can_shared=$GCC ;; >> -- >> 4657- case $cc_basename in >> 4658: nagfor*) >> 4659- # NAG Fortran compiler >> -- >> 4727- ;; >> 4728: nagfor*) >> 4729- # NAG Fortran compiler >> -- >> 5226- tmp_sharedflag='--shared' ;; >> 5227: nagfor*) # NAGFOR 5.3 >> 5228- tmp_sharedflag='-Wl,-shared' ;; >> or ifort: >> % grep -nC1 ifort m4/libtool.m4 >> 1117- case $cc_basename in >> 1118: ifort*|nagfor*) _lt_dar_can_shared=yes ;; >> 1119- *) _lt_dar_can_shared=$GCC ;; >> -- >> 4716- # ICC 10 doesn't accept -KPIC any more. >> 4717: icc* | ifort*) >> 4718- _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' >> -- >> 5219- tmp_addflag=' -i_dynamic' ;; >> 5220: efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 >> 5221- tmp_addflag=' -i_dynamic -nofor_main' ;; >> 5222: ifc* | ifort*) # Intel Fortran compiler >> 5223- tmp_addflag=' -nofor_main' ;; >> Thank you >> Anton > > Here is another patch I generated for this off of the master branch: > > diff --git a/m4/libtool.m4 b/m4/libtool.m4 > index bbf2d21f..4498639f 100644 > --- a/m4/libtool.m4 > +++ b/m4/libtool.m4 > @@ -4387,6 +4387,12 @@ m4_if([$1], [CXX], [ > _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' > _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' > ;; > + *flang* | ftn*) > + # Flang compiler. > + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' > + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' > + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' > + ;; > icpc* ) > # Intel C++, used to be incompatible with GCC. > # ICC 10 doesn't accept -KPIC any more. > @@ -4706,7 +4712,7 @@ m4_if([$1], [CXX], [ > _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' > _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' > ;; > - *flang) > + *flang* | ftn*) > # Flang compiler. > _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' > _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' > > I hope this fixes the issue, but I am having some trouble reproducing > this. If you could provide more information on your flang version, > host OS, and how you are invoking libtool, it would be easier to debug > this. If there is a particular library or test program you are using, > that would also help me. > > -- > Ileana Dumitrescu > > GPG Public Key: FA26 CA78 4BE1 8892 7F22 B99F 6570 EA01 146F 7354 > <OpenPGP_0x6570EA01146F7354.asc>