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

Ipopt build failing with MinGW due to redefinition _matherr #78

Closed
tkralphs opened this issue Feb 8, 2016 · 8 comments
Closed

Ipopt build failing with MinGW due to redefinition _matherr #78

tkralphs opened this issue Feb 8, 2016 · 8 comments

Comments

@tkralphs
Copy link

tkralphs commented Feb 8, 2016

It looks like a fix you originally had in for MinGW is no longer needed as of MinGW gcc 5.3.0 (and perhaps earlier). The Ipopt build fails with redefinition of _matherr because of

#ifdef __MINGW32__
#define matherr _matherr
#endif

For output, see

https://ci.appveyor.com/project/tkralphs/ipopt/build/job/m801jlcxs631phl3

For now, I added a patch to the ASL project project on COIN-OR. This allows the build to go through locally, but the build on Appveyor is still running

@vitaut
Copy link
Contributor

vitaut commented Feb 8, 2016

Thanks for the bug report. What error do you get? https://ci.appveyor.com/project/tkralphs/ipopt/build/job/m801jlcxs631phl3 points to the latest build which is "Reverting r2646" now and I don't see any output there. I tried looking at earlier builds but couldn't find the error you are referring to.

@tkralphs
Copy link
Author

tkralphs commented Feb 8, 2016

Hmm, I guess this URL should work better:

https://ci.appveyor.com/project/tkralphs/ipopt/build/1.0.23/job/m801jlcxs631phl3

The exact error is on line 3646 in the output. Here is a snippet of the link line and error:

[00:50:16] i686-w64-mingw32-g++ -O3 -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -DIPOPT_BUILD -o ipopt.exe ampl_ipopt.o  ./.libs/libipoptamplinterface.a /c/projects/ipopt/build/Ipopt/src/Interfaces/.libs/libipopt.a ../../Interfaces/.libs/libipopt.a /c/projects/ipopt/build/ThirdParty/ASL/.libs/libcoinasl.a /c/projects/ipopt/build/ThirdParty/Mumps/.libs/libcoinmumps.a -LC:/projects/ipopt/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0 -LC:/projects/ipopt/msys64/mingw32/bin/../lib/gcc -LC:/projects/ipopt/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/lib/../lib -LC:/projects/ipopt/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../lib -LC:/projects/ipopt/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/lib -LC:/projects/ipopt/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../.. /c/projects/ipopt/build/ThirdParty/Met
[00:50:16] is/.libs/libcoinmetis.a /c/projects/ipopt/build/ThirdParty/Lapack/.libs/libcoinlapack.a /c/projects/ipopt/build/ThirdParty/Blas/.libs/libcoinblas.a -lgfortran -lmingw32 -lmoldname -lmingwex -lmsvcrt -lquadmath -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32
[00:50:16] C
[00:50:16] :/projects/ipopt/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-merr.o): In function `matherr':
[00:50:16] C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/merr.c:38: multiple definition of `_matherr'
[00:50:16] C:/projects/ipopt/build/ThirdParty/ASL/.libs/libcoinasl.a(fpinit.o):fpinit.c:(.text+0x330): first defined here
[00:50:16] collect2.exe: error: ld returned 1 exit status
[00:50:16] Makefile:494: recipe for target 'ipopt.exe' failed
[00:50:16] make[3]: *** [ipopt.exe] Error 1
[00:50:16] make[3]: Leaving directory '/c/projects/ipopt/build/Ipopt/src/Apps/AmplSolver'
[00:50:16] Makefile:376: recipe for target 'all-recursive' failed
[00:50:16] make[2]: *** [all-recursive] Error 1
[00:50:16] make[2]: Leaving directory '/c/projects/ipopt/build/Ipopt/src/Apps'
[00:50:17] Makefile:677: recipe for target 'all-recursive' failed
[00:50:17] make[1]: *** [all-recursive] Error 1
[00:50:17] make[1]: Leaving directory '/c/projects/ipopt/build/Ipopt'
[00:50:17] Makefile:323: recipe for target 'all-recursive' failed
[00:50:17] make: *** [all-recursive] Error 1
[00:50:17] Command exited with code 2

I guess that your definition of _matherr was to overcome the fact that MinGW did not previously define that symbol, as it should have, and now that bug seems to be fixed.

@vitaut
Copy link
Contributor

vitaut commented Feb 8, 2016

The log suggests that GCC 5.3.0 is used:

mingw-w64-x86_64-gcc-5.3.0-1-any.pkg.tar.xz...

Is it correct?

matherr shouldn't be even compiled on GCC 5+ because the following block defines NO_matherr if __GNUC__ >= 5

#ifdef __GNUC__
#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 5) || __GNUC__ >= 5
#undef NO_matherr
#define NO_matherr
#endif
#endif

and matherr is compiled only if NO_matherr is not defined (too many negations =)):

#ifndef NO_matherr
#ifdef __MINGW32__
#define matherr _matherr
#endif

 matherr_rettype
matherr( struct _exception *e )
{
    switch(e->type) {
      case _DOMAIN:
      case _SING:
        errno = set_errno(EDOM);
        break;
      case _TLOSS:
      case _OVERFLOW:
        errno = set_errno(ERANGE);
      }
    return 0;
    }
#endif /*NO_matherr*/

Note that the GCC 5 check was introduced in 40c1f7f, so make sure that you use a newer version.

@tkralphs
Copy link
Author

tkralphs commented Feb 9, 2016

Ah, OK, I see. There was a bug in the version check, which was fixed by 40c1f7f, as you pointed out, but I guess this commit was never merged to the 2.0 branch, so release 2.0.3 doesn't have it:

https://github.com/ampl/mp/blob/2.0.3/src/asl/solvers/fpinitmt.c#L214

2.0.3 is the most recent release as far as I can see. What is your development scheme? Are you working in master and periodically merging fixes over to stable (2.0 at the moment), then making releases from there? Is what is in master still version 2.0.* or will it eventually become 2.1 or 3.0? In any case, if you could merge that commit to 2.0 and then make a release 2.0.4, that would be helpful.

Actually, even nicer would be to make a release 1.3.1 with the same fix, since Ipopt stable currently depends on ASL 1.3.0 and I can't really bump to 2.0.3 without creating a new stable. I realize that since the 1.3.0 release is from the pre-git era, I guess it might be a bit much to ask :).

@vitaut
Copy link
Contributor

vitaut commented Feb 9, 2016

The master will become 3.0 which I plan to release after fixing some issues with the docs.

Regarding the 2.0 branch, I've been only merging critical fixes there myself, but there were contributed PRs specifically for this branch. Since this is a critical issue I'm going to cherry pick 40c1f7f into 2.0 and release 2.0.4 as you suggest.

I'd rather not bother with 1.x release unless it's really important.

@tkralphs
Copy link
Author

tkralphs commented Feb 9, 2016

OK, I will live with getting a 2.0.4 and will see if we can bump the ASL version without making a new stable. Thanks!

@vitaut
Copy link
Contributor

vitaut commented Feb 9, 2016

@vitaut vitaut closed this as completed Feb 9, 2016
@vitaut
Copy link
Contributor

vitaut commented Feb 10, 2016

And now with the correct version: https://github.com/ampl/mp/releases/tag/2.0.4

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

2 participants