bugGNU Octave - Bugs: bug #61571, mkoctfile: Unresolved symbols when...

 
 

bug #61571: mkoctfile: Unresolved symbols when passing `-l` flags that depend on "base" libraries

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Fri 26 Nov 2021 11:03:28 PM UTC
   
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 7.0.90 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 06 Dec 2021 12:33:38 PM UTC, comment #2: 

No complaints during the week that this was pushed and the motivating example now compiles.

Closing as fixed for now.

Markus Mützel <mmuetzel>
Group administrator
Sun 28 Nov 2021 08:11:46 PM UTC, comment #1: 

I reverted 79369ad5cee6 here:
https://hg.savannah.gnu.org/hgweb/octave/rev/bae2381fb80a

And pushed another patch to the stable branch that re-orders the linker flags here:
https://hg.savannah.gnu.org/hgweb/octave/rev/fc9b98382ea7

I hope we finally got this right and can get rid of LFLAGS in Octave 9. Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Fri 26 Nov 2021 11:03:28 PM UTC, original submission:  

When passing `-l` flags in the command line to `mkoctfile`, they are added after `LDFLAGS` in the command line passed to the linker.
But libraries that resolve symbols must appear after other libraries that use these symbols.

Currently packages are setting `LFLAGS` instead of `LDFLAGS`. Presumably because we are adding the former after manual `-l` flags in the command line to the linker.

`LFLAGS` was removed in Octave 8. I tried to fix compiling the ltfat package by setting `LDFLAGS` instead. But that didn't work:

/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-mkoctfile --verbose -strip -I../src/modules/libltfat/include -DNDEBUG -L../lib -lltfat comp_atrousfilterbank_td.cc
x86_64-w64-mingw32-g++ -c -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include  -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include/octave-8.0.0/octave/.. -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include/octave-8.0.0/octave -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include  -pthread -fopenmp -g -O2 -std=gnu++11 -Wall -DLTFAT_LARGEARRAYS -DLTFAT_BUILD_STATIC -DMINGW=1   -I../src/modules/libltfat/include  -DNDEBUG comp_atrousfilterbank_td.cc -o /tmp/oct-MgVRx0.o
x86_64-w64-mingw32-g++ -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include/octave-8.0.0/octave/.. -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include/octave-8.0.0/octave -I/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/include  -pthread -fopenmp -g -O2 -std=gnu++11 -Wall -DLTFAT_LARGEARRAYS -DLTFAT_BUILD_STATIC -DMINGW=1  -o comp_atrousfilterbank_td.oct  /tmp/oct-MgVRx0.o  -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib  -L"/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib" -L"/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/qt5/lib" -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/lib/gcc/x86_64-w64-mingw32/11.2.0 -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib -lm -lgfortran -lmingw32 -lmoldname -lmingwex -lmsvcrt -lkernel32 -lquadmath -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lkernel32 -lkernel32 -llapack -lblas -lxerbla -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib -lfftw3 -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib -lfftw3f   -L../lib -lltfat -L/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib/octave/8.0.0 -loctinterp -loctave  -Wl,-rpath-link,"/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib" -L"/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/lib" -L"/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/x86_64-w64-mingw32/qt5/lib" -Wl,--export-all-symbols
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0xb9): undefined reference to `fftw_malloc'
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0xc9): undefined reference to `fftw_free'
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0x161): undefined reference to `fftw_malloc'
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0x1b1): undefined reference to `fftw_malloc'
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0x41): undefined reference to `fftw_malloc'
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0x1d1): undefined reference to `fftw_free'
/home/osboxes/Documents/Repositories/Octave/mxe-octave/usr/bin/x86_64-w64-mingw32-ld: ../lib/libltfat.a(dmemalloc.o):memalloc.c:(.text+0x201): undefined reference to `fftw_free'
collect2: error: ld returned 1 exit status


Note that `-lltfat` appears after `-lfftw3` in the linker command. It must be the other way round for it to work.

We should probably exchange the order in which we add linker flags (already for Octave 7):

diff -r 15ae4d97a632 src/mkoctfile.in.cc
--- a/src/mkoctfile.in.cc        Fri Nov 26 22:08:49 2021 +0100
+++ b/src/mkoctfile.in.cc        Fri Nov 26 23:57:30 2021 +0100
@@ -1320,7 +1320,7 @@
             = (vars["CXXLD"] + ' ' + vars["CPPFLAGS"] + ' '
                + vars["ALL_CXXFLAGS"] + ' ' + vars["RDYNAMIC_FLAG"] + ' '
                + pass_on_options + ' ' + output_option + ' ' + objfiles + ' '
-               + libfiles + ' ' + vars["ALL_LDFLAGS"] + ' ' + ldflags + ' '
+               + libfiles + ' ' + ldflags + ' ' + vars["ALL_LDFLAGS"] + ' '
                + vars["LFLAGS"] + ' ' + octave_libs + ' '
                + vars["OCTAVE_LINK_OPTS"] + ' ' + vars["OCTAVE_LINK_DEPS"]);

@@ -1349,8 +1349,8 @@
       std::string cmd
         = (vars["CXXLD"] + ' ' + vars["ALL_CXXFLAGS"] + ' '
            + pass_on_options + " -o " + octfile + ' ' + objfiles + ' '
-           + libfiles + ' ' + vars["DL_LDFLAGS"] + ' ' + vars["LDFLAGS"] + ' '
-           + ldflags + ' ' + vars["LFLAGS"] + ' ' + octave_libs + ' '
+           + libfiles + ' ' + ldflags + ' ' + vars["DL_LDFLAGS"] + ' '
+           + vars["LDFLAGS"] + ' ' + vars["LFLAGS"] + ' ' + octave_libs + ' '
            + vars["OCT_LINK_OPTS"] + ' ' + vars["OCT_LINK_DEPS"]);

 #if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)


Since `LDFLAGS` can still not be used correctly in current versions of Octave, we should probably revert 79369ad5cee6 (for Octave 8) and delay removing `LFLAGS` for at least one or two more major versions.

Markus Mützel <mmuetzel>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-12-06 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-11-28 mmuetzel StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code