1. Problem with euc on Ubuntu Jammy under WSLg

Compiling

function ack(atom m, atom n) 
    if m = 0 then  
        return n + 1 
    elsif m > 0 and n = 0 then 
        return ack(m - 1, 1) 
    else 
        return ack(m - 1, ack(m, n - 1)) 
    end if 
end function 
 
for i = 0 to 4 do 
    for j = 0 to 6 do 
        printf( 1, "%5d", ack( i, j ) ) 
    end for 
    puts( 1, "\n" ) 
end for 

under WSLg and Jammy gives

bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/TEMP$ euc ack.ex 
Build directory: build-609209/ 
Translating code, pass: 1 2 3  generating 
Compiling with GCC 
Compiling  14% init-.c 
Compiling  57% ack.c 
Compiling  85% main-.c 
Linking 100% ../ack 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_w.o): relocation R_X86_64_32 against symbol `screen_image' can not be used when making a PIE object; recompile with -fPIE 
/usr/bin/ld: failed to set dynamic section sizes: bad value 
collect2: error: ld returned 1 exit status 
Unable to link /mnt/c/TEMP/ack 
Status: 1 Command: gcc -o /mnt/c/TEMP/ack  init-.o ack.o main-.o   /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a -m64 -ldl -lm -lpthread 
How do I get it to link?

-Bruce

new topic     » topic index » view message » categorize

2. Re: Problem with euc on Ubuntu Jammy under WSLg

axtens_bruce said...

/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_w.o): relocation R_X86_64_32 against symbol `screen_image' can not be used when making a PIE object; recompile with -fPIE 
/usr/bin/ld: failed to set dynamic section sizes: bad value 
collect2: error: ld returned 1 exit status 
Unable to link /mnt/c/TEMP/ack 
Status: 1 Command: gcc -o /mnt/c/TEMP/ack  init-.o ack.o main-.o   /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a -m64 -ldl -lm -lpthread 
How do I get it to link?

-Bruce

I think the translated makefile respects CCFLAGS, so set CCFLAGS=-fPIE and it should work.

I vaguely remember something like this, I thought we set -fPIE by default. Maybe we only do that when translating to a so (shared library object).

new topic     » goto parent     » topic index » view message » categorize

3. Re: Problem with euc on Ubuntu Jammy under WSLg

Not doing something right here. Version at the end.

bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe$ euc -extra-cflags -fPIE ack.ex 
Build directory: build-456853/ 
Translating code, pass: 1 2 3  generating 
Compiling with GCC 
Compiling  14% init-.c 
Compiling  57% ack.c 
Compiling  85% main-.c 
Linking 100% ../ack 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_w.o): relocation R_X86_64_32 against symbol `screen_image' can not be used when making a PIE object; recompile with -fPIE 
/usr/bin/ld: failed to set dynamic section sizes: bad value 
collect2: error: ld returned 1 exit status 
Unable to link /mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe/ack 
Status: 1 Command: gcc -o /mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe/ack  init-.o ack.o main-.o   /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a -m64 -ldl -lm -lpthread 
Could not remove directory build-456853/ 
 
bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe$ euc -extra-cflags fPIE ack.ex 
Build directory: build-501421/ 
Translating code, pass: 1 2 3  generating 
Compiling with GCC 
Compiling  14% init-.c 
gcc: warning: fPIE: linker input file unused because linking not done 
gcc: error: fPIE: linker input file not found: No such file or directory 
Couldn't compile file 'init-.c' 
Status: 1 Command: gcc  -fomit-frame-pointer -c -w -fsigned-char -O2 -m64 -I/usr/local/euphoria-4.1.0-Linux-x64 -ffast-math fPIE init-.c 
Could not remove directory build-501421/ 
 
bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe$ euc -extra-lflags -fPIE ack.ex 
Build directory: build-507733/ 
Translating code, pass: 1 2 3  generating 
Compiling with GCC 
Compiling  14% init-.c 
Compiling  57% ack.c 
Compiling  85% main-.c 
Linking 100% ../ack 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_w.o): relocation R_X86_64_32 against symbol `screen_image' can not be used when making a PIE object; recompile with -fPIE 
/usr/bin/ld: failed to set dynamic section sizes: bad value 
collect2: error: ld returned 1 exit status 
Unable to link /mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe/ack 
Status: 1 Command: gcc -o /mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe/ack  init-.o ack.o main-.o   /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a -m64 -ldl -lm -lpthread -fPIE 
Could not remove directory build-507733/ 
 
bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe$ euc -v 
Euphoria to C Translator v4.1.0 development 
   64-bit Linux, Using System Memory 
   Revision Date: 2015-02-02 14:18:53, Id: 5861:57179171dbed 

new topic     » goto parent     » topic index » view message » categorize

4. Re: Problem with euc on Ubuntu Jammy under WSLg

jimcbrown said...

I think the translated makefile respects CCFLAGS, so set CCFLAGS=-fPIE and it should work.

I vaguely remember something like this, I thought we set -fPIE by default. Maybe we only do that when translating to a so (shared library object).

Quite the opposite. The problem is that eu.a was compiled without -fPIE as it was not a default at the time. So you need to specify euc -extra-cflags="-no-pie" -extra-lflags="-no-pie" to have the translated code built without PIE. But even then, you'll likely encounter libm version problems (see below). Until we publish a new version, the only good solution is to rebuild the library from source. Even then I'm not sure we'll want to support PIE, just make the translator test for it and emit the flag to avoid it (I'm already doing this in the Euphoria Makefile. It's best to build the library on as old of a machine you have access to (like Debian 9/10 or Ubuntu 18.04) to ensure wides GLIBC/libm compatibility.

Previous discussions of this problem:

-Greg

new topic     » goto parent     » topic index » view message » categorize

5. Re: Problem with euc on Ubuntu Jammy under WSLg

ghaberek said...

So you need to specify euc -extra-cflags="-no-pie" -extra-lflags="-no-pie" to have the translated code built without PIE. But even then, you'll likely encounter libm version problems

Yup.

bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe$  euc -extra-cflags="-no-pie" -extra-lflags="-no-pie"  ack.ex 
Build directory: build-944737/ 
Translating code, pass: 1 2 3  generating 
Compiling with GCC 
Compiling  14% init-.c 
Compiling  57% ack.c 
Compiling  85% main-.c 
Linking 100% ../ack 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_runtime.o): in function `power': 
be_runtime.c:(.text+0x4061): undefined reference to `__powl_finite' 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_runtime.o): in function `Dpower': 
be_runtime.c:(.text+0x40dc): undefined reference to `__powl_finite' 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_runtime.o): in function `e_log': 
be_runtime.c:(.text+0x417f): undefined reference to `__log_finite' 
/usr/bin/ld: /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a(be_runtime.o): in function `De_log': 
be_runtime.c:(.text+0x41c1): undefined reference to `__log_finite' 
collect2: error: ld returned 1 exit status 
Unable to link /mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe/ack 
Status: 1 Command: gcc -o /mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe/ack  init-.o ack.o main-.o   /usr/local/euphoria-4.1.0-Linux-x64/bin/eu.a -m64 -ldl -lm -lpthread -no-pie 

-Bruce

new topic     » goto parent     » topic index » view message » categorize

6. Re: Problem with euc on Ubuntu Jammy under WSLg

Now that's interesting: I was just reading the Makefile for the QB64PE compiler and it's a "-no-pie" as well. @ghaberek you might get some clues from their Makefile. They appear to be using MinGW for the Windows side of things.

-Bruce

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu