Fedora 23 swipl-ld error

37 views
Skip to first unread message

olivier sallou

unread,
Mar 9, 2016, 2:57:18 AM3/9/16
to SWI-Prolog
Hi,
while building my tool on different platforms, I facved a swipl-ld error on Fedora 23 (fine on Fedora-22, ...):
[  366s]      [exec] cc1: error: unrecognized command line option '-mar'

Here is log extract of compilation


[  366s] compile_swi_exe:
[  366s]      [exec] eval `swipl --dump-runtime-variables`
[  366s]      [exec] gcc -c -fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -mar -D_REENTRANT -D__SWI_PROLOG__ -D__SWI_EMBEDDED__ -I/usr/lib/swipl-7.2.3/include -o logolSwiMain.o logolSwiMain.c
[  366s]      [exec] CC="gcc"
[  366s]      [exec] PLBASE="/usr/lib/swipl-7.2.3"
[  366s]      [exec] PLARCH="i686-linux"
[  366s]      [exec] PLLIBS=""
[  366s]      [exec] PLLIB="-lswipl"
[  366s]      [exec] PLCFLAGS="-fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -mar"
[  366s]      [exec] PLLDFLAGS="-rdynamic -Wl,--enable-new-dtags -pthread -Wl,-rpath=/usr/lib/swipl-7.2.3/lib/i686-linux"
[  366s]      [exec] PLSOEXT="so"
[  366s]      [exec] PLTHREADS="yes"
[  366s]      [exec] cc1: error: unrecognized command line option '-mar'
[  366s]      [exec] gcc returned code 256
[  366s]      [exec] *** swipl-ld exit status 1
[  366s]      [exec] Result: 1
[  366s]      [exec] eval `swipl --dump-runtime-variables`
[  366s]      [exec] gcc -c -fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -mar -D_REENTRANT -D__SWI_PROLOG__ -D__SWI_EMBEDDED__ -I/usr/lib/swipl-7.2.3/include -o preSwiMain.o preSwiMain.c
[  366s]      [exec] CC="gcc"
[  366s]      [exec] PLBASE="/usr/lib/swipl-7.2.3"
[  366s]      [exec] PLARCH="i686-linux"
[  366s]      [exec] PLLIBS=""
[  366s]      [exec] PLLIB="-lswipl"
[  366s]      [exec] PLCFLAGS="-fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -mar"
[  366s]      [exec] PLLDFLAGS="-rdynamic -Wl,--enable-new-dtags -pthread -Wl,-rpath=/usr/lib/swipl-7.2.3/lib/i686-linux"
[  366s]      [exec] PLSOEXT="so"
[  366s]      [exec] PLTHREADS="yes"
[  366s]      [exec] cc1: error: unrecognized command line option '-mar'
[  366s]      [exec] gcc returned code 256
[  366s]      [exec] *** swipl-ld exit status 1

Wouter Beek

unread,
Mar 9, 2016, 3:24:18 AM3/9/16
to olivier sallou, SWI-Prolog
Hi Olivier,

I'm also compiling SWI development branch on Fedora 23.  I've recently updated the dependencies installation over at http://www.swi-prolog.org/build/Redhat.html (they're quite different than for Debian-based distro's).

​Also, are you compiling with or without packages?​

---
​Cheers!,
Wouter.

--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.

olivier sallou

unread,
Mar 9, 2016, 3:45:08 AM3/9/16
to SWI-Prolog, olivier...@gmail.com, m...@wouterbeek.com
I use Fedora swipl packages

Jan Wielemaker

unread,
Mar 9, 2016, 3:56:54 AM3/9/16
to olivier sallou, SWI-Prolog, m...@wouterbeek.com
On 03/09/2016 09:45 AM, olivier sallou wrote:
> I use Fedora swipl packages

That was one of the missing pieces :) It seems that the CFLAGS
as compiled into swipl are not acceptable by gcc. It could be
that '-mar' is a truncated version of -marchXXX. Then the question
becomes who truncated what?

Does `pkg-config --cflags swipl` give the right values? If so,
you could use that. If not, I'm afraid you have to work around
in your build scripts or redo the building of SWI-Prolog, so we
can figure out what gets lost in what step.

Cheers --- Jan
> it, send an email to swi-prolog+...@googlegroups.com <javascript:>.
> <https://groups.google.com/group/swi-prolog>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.

olivier sallou

unread,
Apr 12, 2016, 8:37:32 AM4/12/16
to SWI-Prolog, olivier...@gmail.com, m...@wouterbeek.com
I have an other issue on Fedora 23, with -mtu being unrecognized too (using swi-pl from Fedora 23 repository)
though not having -march on this one....

olivier sallou

unread,
Apr 13, 2016, 2:00:15 AM4/13/16
to SWI-Prolog, olivier...@gmail.com, m...@wouterbeek.com
Adding log:

swipl-ld -Lm   -goal true -initfile swi-logol.pl -o preanalyse.exe -v preSwiMain.c sicstus.pl logol.pl eval `swipl --dump-runtime-variables`
CC="gcc"
PLBASE="/usr/lib64/swipl-7.2.3"
PLARCH="x86_64-linux"
PLLIBS=""
PLLIB="-lswipl"
PLCFLAGS="-fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtu"
PLLDFLAGS="-rdynamic -Wl,--enable-new-dtags -pthread -Wl,-rpath=/usr/lib64/swipl-7.2.3/lib/x86_64-linux"
PLSOEXT="so"
PLTHREADS="yes"
gcc -c -fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtu -D_REENTRANT -D__SWI_PROLOG__ -D__SWI_EMBEDDED__ -I/usr/lib64/swipl-7.2.3/include -o preSwiMain.o preSwiMain.c
cc1: error: unrecognized command line option '-mtu'


Jan Wielemaker

unread,
Apr 13, 2016, 3:13:53 AM4/13/16
to olivier sallou, SWI-Prolog, m...@wouterbeek.com
Hi Olivier,

I don't really understand what is going on. PLCFLAGS is initialized from
the Prolog flag `c_cflags`, which is in turn set during the build
process from the CFLAGS used. No clue what -mtu means (see manual), but
I'd assume if they use a particular set of flags for compiling the
packages you can use the same flags for compiling your own applications
... Apparently this assumption is wrong!?

I guess you have at least these options: (1) file an issue with Fedora
and see what they have to say, (2) compile Prolog from source. Default
compilation uses flags that work or (3): use plain gcc for compiling
instead of swipl-ld and (4), see whether pkg-config can do the job
for you. If the installation is complete, SWI-Prolog should be
registered as `swipl`, e.g.

ct2 (~) 5_> pkg-config --cflags swipl
-fno-strict-aliasing -pthread -fPIC -I/home/jan/lib/swipl/include

Compiling extensions for SWI-Prolog on Linux isn't too hard. You
basically need -fPIC and the proper -I to get SWI-Prolog.h. Linking
the shared object doesn't even need to link libswipl.so, so the generic

gcc -shared -o myext.so -fPIC -I/path/to/swi/include input ...

should do.


Cheers --- Jan


On 04/13/2016 08:00 AM, olivier sallou wrote:
> Adding log:
>
> swipl-ld -Lm -goal true -initfile swi-logol.pl -o preanalyse.exe -v
> preSwiMain.c sicstus.pl logol.pleval `swipl --dump-runtime-variables`
> CC="gcc"
> PLBASE="/usr/lib64/swipl-7.2.3"
> PLARCH="x86_64-linux"
> PLLIBS=""
> PLLIB="-lswipl"
> PLCFLAGS="-fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall
> -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches
> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtu"
> PLLDFLAGS="-rdynamic -Wl,--enable-new-dtags -pthread
> -Wl,-rpath=/usr/lib64/swipl-7.2.3/lib/x86_64-linux"
> PLSOEXT="so"
> PLTHREADS="yes"
> gcc -c -fno-strict-aliasing -pthread -fPIC -O2 -g -pipe -Wall
> -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches
> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtu -D_REENTRANT
> -D__SWI_PROLOG__ -D__SWI_EMBEDDED__ -I/usr/lib64/swipl-7.2.3/include -o
> preSwiMain.o preSwiMain.c
> cc1: error: unrecognized command line option '-mtu'
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

olivier sallou

unread,
Apr 13, 2016, 3:21:23 AM4/13/16
to Jan Wielemaker, SWI-Prolog, m...@wouterbeek.com
I gonna check with Fedora first

Thanks

olivier sallou

unread,
Apr 13, 2016, 7:18:59 AM4/13/16
to SWI-Prolog, J.Wiel...@vu.nl, m...@wouterbeek.com
Someone made a look at Fedora, here is the answer. It seems to be a bug in swipl-ld.c


I think I found it. It's a bug in SWI swipl-ld. The src/swipl-ld.c parses
"swipl --dump-runtime-variables" output. It segments lines into 256-byte long
buffer. And fgets(3) hits the 256-byte limit on PLCFLAGS value:

Fedora 22:

$ swipl --dump-runtime-variables | grep PLCFLAGS | wc -c
222

Fedora 23:

$ swipl --dump-runtime-variables | grep PLCFLAGS | wc -c
268

Jan Wielemaker

unread,
Apr 13, 2016, 7:28:06 AM4/13/16
to olivier sallou, SWI-Prolog, m...@wouterbeek.com
On 04/13/2016 01:18 PM, olivier sallou wrote:
> Someone made a look at Fedora, here is the answer. It seems to be a bug
> in swipl-ld.c

That is quick! Pushed a fix (well, enlarged to 1024 chars) swipl-ld
isn't really rocket science, but better than writing both a bash and
a Windows cmd file :) Well, I understand bash is arriving on Windows :)

I fear you still need to use one of the workarounds until Fedora picked
up the new version.

Cheers --- Jan
Reply all
Reply to author
Forward
0 new messages