Libtool is discarding `-static` flag
Asked Answered
Y

1

9

I am building flex-2.5.39 which I configured using:

./configure --enable-static LDFLAGS=-static CC=/x86_64-linux-musl/bin/x86_64-linux-musl-gcc

But at the very end, libtool is not linking statically. It is, in fact, simply discarding the flag:

[ root@836843e09b55:/flex-2.5.39 ]$ make flex
/bin/bash ./libtool --tag=CC   --mode=link /x86_64-linux-musl/bin/x86_64-linux-musl-gcc  -g -O2  -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o lib/libcompat.la -lm 
libtool: link: /x86_64-linux-musl/bin/x86_64-linux-musl-gcc -g -O2 -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o  lib/.libs/libcompat.a -lm
[ root@836843e09b55:/flex-2.5.39 ]$

How can I make libtool accept the flag and pass it on?

Yearly answered 14/3, 2015 at 21:13 Comment(0)
Y
12

Using --static (extra minus), it works.

Yearly answered 14/3, 2015 at 22:44 Comment(4)
Thank you for this answer. It's would be great to know if there's some logic behind this behavior or it's just a bug in libtool.Impressible
Worked for me when building openvpn. Usually "-static" is enough but something about the way openvpn links the final executable using libtool requires "--static".Vestpocket
@Impressible It really seems like a bug to me... I Initially thought the extra minus would act as an escape character and that the linker would effectively get a -static, but the linker really gets a --static. So it seems it's only luck that (1) libtool does not recognize and filter out --static and that (2) ld recognize --static (which by its man page, shouldn't be the case). It works, but it's not something we should strongly rely on.Cavatina
@YvesLhuillier I wish someone more informed than me could file a bug about this...Impressible

© 2022 - 2024 — McMap. All rights reserved.