gobo-eiffel / gobo

The Gobo Eiffel Project provides the Eiffel community with free and portable Eiffel tools and libraries.
https://sourceforge.net/projects/gobo-eiffel/
Other
59 stars 24 forks source link

Fixed iconv build issue for Mac OS X #48

Closed chayward closed 4 years ago

chayward commented 4 years ago

Executing "geant test_debug_ge" results in failed tests under Mac OS X. This is caused because the iconv library is not correctly linked.

Modified the iconv-config script to return the correct result under Mac OS X.

ebezault commented 4 years ago

The code in $GOBO/library/free_elks/src is maintained by ISE. I will forward this pull request to them.

chayward commented 4 years ago

If ISE's compiler is installed then the previous version of iconv-config script works.

ebezault commented 4 years ago

I think that the reason is that gec does not set the variable $ISE_PLATFORM. So the script does not execute this part:

elif echo "$ISE_PLATFORM" | grep "macosx" >/dev/null 2>&1; then

When ISE's compiler is installed, then $ISE_PLATFORM is defined, and the script works as expected. I wonder whether just adding:

        else # Potentially sensible default for unknown platform
            echo -liconv

in the script would be enough for it to work with gec even when $ISE_PLATFORM is not defined.

chayward commented 4 years ago

Adding just the else block's will work.

ebezault commented 4 years ago

I was told by someone at ISE that adding just the else block does not work on other platforms such as Ubuntu. So it looks like the only solution left is to find a way for gec to set the variable $ISE_PLATFORM behind the scene (and in the meantime the users should set it manually when they don't have ISE's compiler installed).

ebezault commented 4 years ago

I pushed new code in the master branch where gec should be able to set the environment variable $ISE_PLATFORM behind the scene if not already set. Can you check whether this solves the problem on MacOSX with iconv when ISE's compiler is not installed? You will need to recompile gec first.

jocelyn commented 4 years ago

Probably adding the cases with uname would also be possible, but clearly having the "-liconv" as default in the else may cause more troubles.

ebezault commented 4 years ago

Is there a guarantee that uname is available on all platform on which this script is supposed to run?

chayward commented 4 years ago

I pushed new code in the master branch where gec should be able to set the environment variable $ISE_PLATFORM behind the scene if not already set. Can you check whether this solves the problem on MacOSX with iconv when ISE's compiler is not installed? You will need to recompile gec first.

This change does not fix the problem.

In gobo/library/parse/example/scalc running geant compile_ge

"Degree 6: 0/0/0 0:0:0.020 Degree 5: 0/0/0 0:0:0.120 Degree 4: 0/0/0 0:0:0.057 Degree 3: 0/0/0 0:0:0.092 Degree -2: 0/0/0 0:0:0.104 Degree -3: 0/0/0 0:0:0.065 Total Time: 0/0/0 0:0:0.459 Undefined symbols for architecture x86_64: "_iconv", referenced from: _T115f42 in scalc1.o "_iconv_open", referenced from: _T115f16 in scalc1.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

BUILD FAILED!"

If I modify the generated "scalc.sh" to export the ISE_PLATFORM variable in the shell script then it successfully builds. Like this:

!/bin/sh

clang -Wno-unused-value -Wno-deprecated-declarations export ISE_PLATFORM=macosx;/Users/chayward/src/gobosoft_github_original/gobo/library/free_elks/src/elks/encoding/implementation/unix/Clib/iconv-config --include_path -I"/Users/chayward/src/gobosoft_github_original/gobo/library/free_elks/src/elks/encoding/implementation/include" -c scalc1.c clang export ISE_PLATFORM=macosx;/Users/chayward/src/gobosoft_github_original/gobo/library/free_elks/src/elks/encoding/implementation/unix/Clib/iconv-config --library -o scalc scalc1.o -lm

ebezault commented 4 years ago

OK, I understand. The variable $ISE_PLATFORM is set in gec, but geant compile_ge compiles the generated C code after gec has been executed (not while executing gec as it would be the case when using gec directly instead of geant compile_ge). I'll make sure that $ISE_PLATFORM is also set when compiling the C code outside of gec.

ebezault commented 4 years ago

I think that this time everything should work as expected. You will have to recompile both gec and gecc before giving it a try.

chayward commented 4 years ago

That fixes it!