Opened 4 years ago

Closed 4 years ago

#6148 closed defect (fixed)

OpenModelica does not compile on Gentoo

Reported by: leoricupero@… Owned by: Martin Sjölund
Priority: normal Milestone: 1.16.0
Component: Build Environment Version: v1.16.0-dev
Keywords: Cc:

Description (last modified by Mahder Alemseged Gebremedhin)

Hi,
I'm trying to compile OpenModelica from GIT sources on my Gentoo installation. I was able to compile it successfully until version 1.13. I even started creating an ebuild for it.
Now it's been some time that I'm not able to compile it anymore. In the attached build log (it's not a clean build, but the error is the same) you can see that the compiler fails here:

clang -c -o "om_unzip.o" "om_unzip.c" -g -O2 -fno-stack-protector -fPIC  -Wno-parentheses-equality -Wno-unused-variable -Werror=implicit-function-declaration -Werror=incompatible-pointer-types  -I../../SimulationRuntime/c -I../../SimulationRuntime/c/simulation/results -I../../SimulationRuntime/c/util -I../../SimulationRuntime/c/meta -I../../SimulationRuntime/c/meta/gc -I.  -DGC_THREADS -I../../3rdParty/gc/include -I../../3rdParty/FMIL/install/include -I../../3rdParty/graphstream/gs-netstream/c++/src/ -I../../3rdParty/metis-5.1.0/include -I../../3rdParty/cJSON -I../../3rdParty/libzmq/include -I../boot/tarball-include -I..
In file included from om_unzip.c:4:
In file included from ./../../3rdParty/FMIL/ThirdParty/Minizip/minizip/unzip.h:55:
./../../3rdParty/FMIL/ThirdParty/Minizip/minizip/ioapi.h:135:45: error: expected ';' after top level declarator
typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
                                            ^
                                            ;

I think the root cause is that on my system I already have minizip installed. In fact, I've been able to successfully build OpenModelica if I simply modify the include of the boundled minizip library:

#include "../../3rdParty/FMIL/ThirdParty/Minizip/minizip/unzip.h"

with my system minizip

#include <minizip/unzip.h>

Of course I'd like to have this fixed in the build system, which should detect the presence of the system's library and use that when available.

Thanks!
Leo

Attachments (3)

build.log (54.1 KB ) - added by leoricupero@… 4 years ago.
ioapi.c.i (85.3 KB ) - added by leoricupero@… 4 years ago.
om_unzip.c.i (235.0 KB ) - added by leoricupero 4 years ago.

Download all attachments as: .zip

Change History (14)

by leoricupero@…, 4 years ago

Attachment: build.log added

comment:1 by Francesco Casella, 4 years ago

Milestone: Future1.17.0

comment:2 by Mahder Alemseged Gebremedhin, 4 years ago

You can try to go to /OpenModelica/OMCompiler/3rdParty/FMIL/build/Config.cmake/Minizip directory and then run

make __/__/ThirdParty/Minizip/minizip/ioapi.i

*Note that those are double underscores. Tab completion can help you as well.

Then find this file
OpenModelica/OMCompiler/3rdParty/FMIL/build/Config.cmake/Minizip/CMakeFiles/minizip.dir/__/__/ThirdParty/Minizip/minizip/ioapi.c.i

and attach it here so we can make more sense of what happened. You can also search for "# 135" in this file to see what caused the error.

comment:3 by Mahder Alemseged Gebremedhin, 4 years ago

Description: modified (diff)

by leoricupero@…, 4 years ago

Attachment: ioapi.c.i added

comment:4 by Martin Sjölund, 4 years ago

I guess we would need to get a similar file for om_unzip.o because ioapi.c.i looks fine and compiles without problem.

cd /OpenModelica/OMCompiler/Compiler/runtime/
clang -E -o "om_unzip.c.i" "om_unzip.c" -g -O2 -fno-stack-protector -fPIC  -Wno-parentheses-equality -Wno-unused-variable -Werror=implicit-function-declaration -Werror=incompatible-pointer-types  -I../../SimulationRuntime/c -I../../SimulationRuntime/c/simulation/results -I../../SimulationRuntime/c/util -I../../SimulationRuntime/c/meta -I../../SimulationRuntime/c/meta/gc -I.  -DGC_THREADS -I../../3rdParty/gc/include -I../../3rdParty/FMIL/install/include -I../../3rdParty/graphstream/gs-netstream/c++/src/ -I../../3rdParty/metis-5.1.0/include -I../../3rdParty/cJSON -I../../3rdParty/libzmq/include -I../boot/tarball-include -I..

And attach om_unzip.c.i

comment:5 by leoricupero, 4 years ago

Probably I'm missing something, but to me it seems that the issue in ioapi is that the OF macro is not defined:

# 135 "/home/leo/builds/OpenModelica/OMCompiler/3rdParty/FMIL/ThirdParty/Minizip/minizip/ioapi.h"
3511	typedef voidpf ( *open_file_func) (voidpf opaque, const char* filename, int mode);
3512	typedef uLong ( *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
3513	typedef uLong ( *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
3514	typedef int ( *close_file_func) (voidpf opaque, voidpf stream);
3515	typedef int ( *testerror_file_func) (voidpf opaque, voidpf stream);

If you compare this output with the one from my build.log, you see that the OF macro expansion is empty.
I will provide the om_unzip.c.i file as soon as I have access to my PC at home.
Thanks!

comment:6 by Mahder Alemseged Gebremedhin, 4 years ago

We are trying to figure out why the OF macro is empty in your case (if it is empty).
There is a chain of #defines that enable the macro OF any one of them might be undefined.

The OF macro itself is defined in zconf.h and there are a number of zconf.h files (at least 4 in OpenModelica and your installation). This way we can see which zconf.h is included in the different compilations.

Also the macro OF disappearing should not have caused that error by itself. You will just get this

typedef voidpf ( *open_file_func);

It seems to me like the semicolon after the macro is disappearing as well. This can not happen so there is something more going on.

by leoricupero, 4 years ago

Attachment: om_unzip.c.i added

comment:7 by Martin Sjölund, 4 years ago

Ah, yes... It's including /usr/include/zlib.h and not the correct one... zconf.h is not available until it is built and it seems we are including the source directory.

comment:9 by Martin Sjölund, 4 years ago

Try re-compiling it with the updated sources. It should work fine.

comment:10 by leoricupero, 4 years ago

I just recompiled it. It worked!
Thanks!

comment:11 by Martin Sjölund, 4 years ago

Milestone: 1.17.01.16.0
Resolution: fixed
Status: newclosed

OK, I'll backport it to 1.16

Note: See TracTickets for help on using tickets.