0

There is a project (Antlr3 for C) that can be built with ./configure && make && make install.

One of the flags that are used in the compilation command is -Wl,-soname -Wl,libantlr3c.so. The whole command is:

libtool: link: gcc -shared  .libs/antlr3baserecognizer.o .libs/antlr3basetree.o \
.libs/antlr3basetreeadaptor.o .libs/antlr3bitset.o .libs/antlr3collections.o \
.libs/antlr3commontoken.o .libs/antlr3commontree.o .libs/antlr3commontreeadaptor.o \
.libs/antlr3commontreenodestream.o .libs/antlr3convertutf.o .libs/antlr3cyclicdfa.o \
.libs/antlr3debughandlers.o .libs/antlr3encodings.o .libs/antlr3exception.o \
.libs/antlr3filestream.o .libs/antlr3inputstream.o .libs/antlr3intstream.o \
.libs/antlr3lexer.o .libs/antlr3parser.o .libs/antlr3rewritestreams.o \
.libs/antlr3string.o .libs/antlr3tokenstream.o .libs/antlr3treeparser.o    \
-m64   -Wl,-soname -Wl,libantlr3c.so -o .libs/libantlr3c.so

How can I remove only the -Wl,-soname -Wl,libantlr3c.so part?

I understand that the compiler and linker flags can be overridden with CFLAGS and LDFLAGS in the configure command. According to this link, it's something like

./configure CFLAGS=blah LDFLAGS=blah

Although I understand that they can/should be used as environment variables, something like

CFLAGS=BLAH LDFLAGS=blah ./configure

However, I think that those uses would try to override all the CFLAGS or LDFLAGS. I only want to exclude the -soname flag (which, I understand, -Wl, means that the compiler passes a flag to the linker.

None of my attempts with things like LDFLAGS=-soname= or CFLAGS="-Wl,soname -Wl,", and variations of them, were successful so far.

From this question it looks as if it was possible to remove flags from within a Makefile, but I can't see that being applicable to overriding flags from the command line with the configure command. It's also possible to provide these variables to the make command instead of the configure command, but that wasn't successful either.

Note, it wouldn't make sense for me to change the Makefile, since it's generated out of the configure command.

Community
  • 1
  • 1
jleeothon
  • 2,907
  • 4
  • 19
  • 35

1 Answers1

0

You cannot remove -soname because it's part of the way you build a shared library with GCC, and comes straight from libtool. Since you can't really build a shared object for ELF without a soname (well, you can, but it's not really useful) libtool won't let you remove that.

You probably are better off declaring what you try to achieve, because I have a feeling it has nothing really to do with -soname in that case.

Diego Elio Pettenò
  • 3,152
  • 12
  • 15
  • I am familiar with this issue. Antlr3 is a dependency of a library in a package management system where dependencies are linked by providing the fully qualified path to gcc, without using -l. This hardcodes the path in the executable which in this case is exactly what we need. Only exception is when dependency is built with -soname, where not the full path is hardcoded, but the specified name. This forces us to install Antlr3 to /usr/local/lib, which clutters the environment. – Sander Mertens Oct 24 '16 at 23:23