bugGNU Octave - Bugs: bug #48215, MacOS: mkoctfile linker error -...

 
 

bug #48215: MacOS: mkoctfile linker error - configure.ac produces wrong MKOCTFILE_DL_LDFLAGS (PATCH)

Submitter:  Friedrich Beckmann <beckmanf>
Submitted:  Mon 13 Jun 2016 12:28:30 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:  * dev Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 21 Jun 2016 04:49:22 PM UTC, comment #15: 

Thanks for the followups. I think I may have confused myself earlier also.

In any case, the "builddir" is always going to be the current directory when you are building Octave. So the bare directory "libinterp" refers to the libinterp subdir in the build directory, and since we now do non-recursive building, that is always correct. It could also be spelled "./libinterp", but either way the build directory is always the current directory.

I'm not sure about the "libinterp/octave" name, though, but unless/until someone reports an error with that set of options I don't see a reason to change it for this bug.

Closing again, ok?

Mike Miller <mtmiller>
Group Member
Tue 21 Jun 2016 07:52:33 AM UTC, comment #14: 

Mike,

The patch is OK for me and I don't see any reason to change it.

But, just for completeness, I am NOT building with './configure' and my 'builddir' does not coincide with 'srcdir'.

I have a source directory named 'octave' and a build directory named 'build_default' which are on the same level and I run '../octave/configure' from within 'build_default' so in my case I guess '$builddir' should expand to '../build_default' or something similar?

 


Carlo de Falco <cdf>
Group Member
Thu 16 Jun 2016 06:33:15 PM UTC, comment #13: 

Hi Mike,

Here is what I get on MacOS with my proposed patch but only for

DL_LDFLAGS
MKOCTFILE_DL_LDFLAGS

i.e. without SHLEXT_VER, SHLLIB_VER and SHLBIN_VER.


pool8021x167-207:~ fritz$ mkoctfile -p DL_LDFLAGS
-bundle -bundle_loader /opt/local/bin/octave-4.1.0+
pool8021x167-207:~ fritz$ octave --eval "__octave_config_info__ DL_LDFLAGS"
ans = -bundle -bundle_loader /libinterp/octave -L/opt/local/lib -Wl,-headerpad_max_install_names
pool8021x167-207:~ fritz$ octave --eval "version"
ans = 4.1.0+
pool8021x167-207:~ fritz$


With your patch it looks like this:


pool8021x167-207:octave-devel fritz$ mkoctfile -p DL_LDFLAGS
-bundle -bundle_loader /opt/local/bin/octave-4.1.0+
pool8021x167-207:octave-devel fritz$ octave --eval "__octave_config_info__ DL_LDFLAGS"
ans = -bundle -bundle_loader libinterp/octave -L/opt/local/lib -Wl,-headerpad_max_install_names
pool8021x167-207:octave-devel fritz$


Please note that with your patch the leading / is missing, i.e.

libinterp/octave

vs.

/libinterp/octave

Friedrich

Friedrich Beckmann <beckmanf>
Thu 16 Jun 2016 06:22:53 PM UTC, comment #12: 

I think this variable is actually only used now when cross-compiling, and I think the path used to be correct when "libinterp" was "src", possibly something got lost along the way.

Mike Miller <mtmiller>
Group Member
Thu 16 Jun 2016 06:17:57 PM UTC, comment #11: 

Thanks. That's actually what I intended it to be, since it should be $builddir/libinterp/octave, and assuming you built with ./configure, that's right. I think this variable is mainly used for building things inside the build tree, so that is correct as far as it should be.

Now if that variable is not actually used anywhere, or not really needed in octave_config_info, maybe we can delete that like the other obsolete build vars I cut out recently.

I've pushed this on default now, thanks to both of you for the patches and testing.

http://hg.savannah.gnu.org/hgweb/octave/rev/a53f46577e39

Mike Miller <mtmiller>
Group Member
Thu 16 Jun 2016 05:36:48 PM UTC, comment #10: 

Mike,
With your changeset applied I still get:



$ mkoctfile -p DL_LDFLAGS
-bundle -bundle_loader /opt/octave/4.1/bin/octave-4.1.0+

$ octave --eval "__octave_config_info__ DL_LDFLAGS"
ans = -bundle -bundle_loader libinterp/octave -L/opt/local/lib -m64


This does not look right to me, does it?

Carlo de Falco <cdf>
Group Member
Thu 16 Jun 2016 04:23:02 PM UTC, comment #9: 



Here is what I get:


$ mkoctfile -p DL_LDFLAGS
-bundle -bundle_loader /opt/octave/4.1/bin/octave-4.1.0+

$ octave --eval "__octave_config_info__ DL_LDFLAGS"
ans = -bundle -bundle_loader /libinterp/octave -L/opt/local/lib -m64

$ octave --eval "version"
ans = 4.1.0+


indeed the value in _octave_config_info_  does look a bit fishy, I'll try your changeset instead.


Carlo de Falco <cdf>
Group Member
Thu 16 Jun 2016 03:45:16 PM UTC, comment #8: 

Sorry for asking for one more round of testing. I think there are still some small problems with this change and I want to be sure to get them all.

What are the values of


mkoctfile -p DL_LDFLAGS
octave --eval "__octave_config_info__ DL_LDFLAGS


with the current proposed patch applied? I suspect the octave_config_info value may not quite correct.

Please try the attached changeset instead, which is what I intend on pushing if it works for you. This should expand the variable values at the right time for both sets of flags.

(file #37504)

Mike Miller <mtmiller>
Group Member
Thu 16 Jun 2016 08:57:32 AM UTC, comment #7: 

Mike, Friederich,

The patch seems to fix the issue for me, now
with the patch applied I get:


$ grep -i -C1 DL_LDFLAGS src/mkoctfile.cc
  vars["DL_LD"] = get_variable ("DL_LD", "g++ -std=gnu++11");
  vars["DL_LDFLAGS"] = get_variable ("DL_LDFLAGS",
                                     "-bundle -bundle_loader /opt/octave/4.1/bin/octave-4.1.0+");
--
"                            DL_LD                       OCTAVE_PREFIX\n"
"                            DL_LDFLAGS                  OCTINCLUDEDIR\n"
"                            F77                         OCTLIBDIR\n"
--
                            + vars["ALL_CXXFLAGS"] + " "
                            + vars["DL_LDFLAGS"] + " "
                            + pass_on_options



and, after build, I get a working mkoctfile.

Thanks Friederich for this fix, I think it should be pushed ASAP.

c.


Carlo de Falco <cdf>
Group Member
Wed 15 Jun 2016 05:57:38 PM UTC, comment #6: 

Carlo, thanks for pointing to that earlier thread. No replies, maybe not many macOS users are working from the default branch?

I'll wait for results from your test of the patch. It looks good to me, I'd maybe add a comment to separate the earlier variables which are all "dir" variables from these build flag variables.

I've also now deleted all the other variables touched by this patch, since they are completely obsolete and unused.

Mike Miller <mtmiller>
Group Member
Wed 15 Jun 2016 10:39:26 AM UTC, comment #5: 

Hi,

This is the same problem I had reported here:
http://octave.1599824.n4.nabble.com/DL-LDFLAGS-td4676998.html

I was not sure whether it was a bug as I was (and still am) very surprised that no other OSX users were seeing the same issue!

I'll test the patch and report back.


Carlo de Falco <cdf>
Group Member
Tue 14 Jun 2016 01:02:41 PM UTC, comment #4: 

Looking at the mentioned patch, all variables which use "version" will expand to zero if they are set before line 8.156. Therefore 8.50, 8.51 and 8.52 should not work. SHLEXT_VER will yield "so.", because version is not set at that point.

Mike questioned that these variable are useful at all because they are maybe not be used. I cannot judge that. But from my perspective the mentioned change

 http://hg.savannah.gnu.org/hgweb/octave/rev/1aa293d58df0

is not correct for the variables SHLEXT_VER, SHLLIB_VER and SHLBIN_VER.

The variables

DL_LDFLAGS
MKOCTFILE_DL_LDFLAGS

do not work for the MacOS case which was not considered in the patch. For the MacOS case they use the "version" variable and the "top_builddir" or "bindir" variable. The setting itself is o.k., i.e. when this is fully expanded, then it works for me in macports.



Friedrich Beckmann <beckmanf>
Tue 14 Jun 2016 11:47:37 AM UTC, comment #3: 

I'm not sure of the correct setting of the flags for OS X, but if these variables need things like ${bindir} or ${version} embeded in them, then the patch is the right thing to do.

See also bug #46063 and http://hg.savannah.gnu.org/hgweb/octave/rev/1aa293d58df0

John W. Eaton <jwe>
Group administrator
Mon 13 Jun 2016 08:07:41 PM UTC, comment #2: 

Hi Mike,

thanks for your comment. I only left the changes to MKOCTFILE_DL_LDFLAGS and DL_LDFLAGS and then still mkoctfile works for me. So I cannot see what is not working when the other variables are not changed.

Friedrich

Friedrich Beckmann <beckmanf>
Mon 13 Jun 2016 03:50:10 PM UTC, comment #1: 

Thanks for the detailed bug report and patch. It does look like some form of expansion is needed for DL_LDFLAGS and MKOCTFILE_DL_LDFLAGS on OS X. Only OS X contains variable expansions within those variable definitions. Can any other OS X users confirm that something needs to be fixed here for building oct-files or mex-files?

The other variables (SHLEXT_VER, SHLLIB_VER, and SONAME_FLAGS) don't even seem to be used anywhere in Octave anymore, they may be completely obsolete. I wouldn't change anything in those unless you can show that they are used and necessary for your use case.

Mike Miller <mtmiller>
Group Member
Mon 13 Jun 2016 12:28:30 PM UTC, original submission:  

Hi,

i tried to use the development version octave-devel on macports for building octave 4.1.0+ which is hg version 19e8eddd4773 on MacOS.

The following error is produced, when I use mkoctfile to compile a mex file


FriedrichsMacBook:minFunc fritz$ mkoctfile-4.1.0+ -v --mex lbfgsC.c
/usr/bin/clang -c -I/opt/local/include -fPIC -I/opt/local/include/octave-4.1.0+/octave/.. -I/opt/local/include/octave-4.1.0+/octave -I/opt/local/include  -D_THREAD_SAFE -pthread -pipe -Os -arch x86_64   -I.  lbfgsC.c -o lbfgsC.o
/usr/bin/clang++ -std=gnu++11 -I/opt/local/include/octave-4.1.0+/octave/.. -I/opt/local/include/octave-4.1.0+/octave -I/opt/local/include  -D_THREAD_SAFE -pthread -pipe -Os -arch x86_64 -stdlib=libc++ -bundle -bundle_loader /bin/octave-  -o lbfgsC.mex  lbfgsC.o   -L/opt/local/lib/octave/4.1.0+ -L/opt/local/lib -loctinterp -loctave -L/opt/local/lib -Wl,-headerpad_max_install_names  -L/opt/local/lib/hdf5-18 -L/opt/local/lib                    -L/opt/local/lib -lfreetype -lhdf5 -lGraphicsMagick++ -lGraphicsMagick -lz -lfftw3_threads -lfftw3 -lfftw3f_threads -lfftw3f -Wl,-framework -Wl,OpenGL -L/opt/local/lib -lfontconfig -lfreetype   -Wl,-framework -Wl,Carbon -lgl2ps                 -lcurl -lcholmod -lsuitesparseconfig -lumfpack -lsuitesparseconfig -lamd -lsuitesparseconfig -lcamd -lsuitesparseconfig -lcolamd -lsuitesparseconfig -lccolamd -lcxsparse -lsuitesparseconfig -larpack -lqrupdate -lfftw3_threads -lfftw3 -lfftw3f_threads -lfftw3f  -lvecLibFort -lreadline -lncurses  -L/opt/local/lib -lpcre -ldl   -L/opt/local/lib -L/opt/local/lib/gcc5/gcc/x86_64-apple-darwin15/5.4.0 -L/opt/local/lib/gcc5/gcc/x86_64-apple-darwin15/5.4.0/../../.. -lgfortran -lquadmath -lm -lm
clang: warning: argument unused during compilation: '-pthread'
ld: file not found: /bin/octave-
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FriedrichsMacBook:minFunc fritz$


The reason for the problem is a wrong setting of the MKOCTFILE_DL_LDFLAGS variable in configure.ac. The reason for that is that the variable "version" is not set at that point of time - it is empty. The handling of variables like "octfiledir" is different, as these variables are taken first literally, i.e. ${version} is not expanded at that point of time, but later after version has been set to OCTAVE_VERSION in line 3351, they are expanded.

The same problem is there for other variables. I made a patch versus the configure.ac version that is already patched in macports, so the line numbers may vary vs. the current hg version.

The patch follows the idea of the directory variables which are explicitly expanded.

I tested this in the macports environment and there I can compile the mex files with this patch.

Friedrich Beckmann <beckmanf>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37504:  macos-ldflags.patch added by mtmiller (2KiB - text/x-diff)
file #37464:  patch-configure-mkoctfile.patch added by beckmanf (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cdf (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by beckmanf (Submitted the item)
  • -email is unavailable- added by beckmanf
  •  

    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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-21 mtmiller StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-06-21 cdf StatusFixed Patch Submitted
        Open/ClosedClosed Open
    2016-06-16 mtmiller StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-06-16 mtmiller Attached File- Added macos-ldflags.patch, #37504
        StatusNeed Info Patch Submitted
    2016-06-13 mtmiller StatusNone Need Info
    2016-06-13 beckmanf Attached File- Added patch-configure-mkoctfile.patch, #37464
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code