Support for different compilers

Magnus Ihse Bursie magnus.ihse.bursie at
Tue Feb 4 09:22:15 UTC 2014

On 2014-02-04 04:49, Martin Buchholz wrote:
> I'll concede that when determining default compiler flags, those are 
> highly dependent on something like a "compiler family" and cannot be 
> done in the C/C++ sources themselves.  But even then, for many of the 
> compiler flags there should be feature based autoconf tests instead of 
> relying on guessing based on compiler family, e.g. does -Wl,-rpath work?

I object strongly to this. From time to time, "feature based tests" is 
popped into the discussion. While it might sound good in theory, let's 
look at what that actually mean in practice.

Let's take your example, "does -Wl,-rpath work?" What do you mean by 
* That the compiler accept the argument without failing? Sure, that's 
not so hard to test, but what does it tell you?
* That it produces output with certain characterstics? How do you 
determine if that is the case? Analyze the resulting binary with a tool? 
Does that tool work properly? How do you test *that*, if you don't trust 
anything? Otherwise you're just shifting your assumption from how the 
compiler works to how the tool works.

And the complexity! Let's go real life. Look at the value of 
for gcc on macosx:
'-Xlinker -rpath -Xlinker @loader_path/.'
for gcc on linux:
'-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
for oracle solaris studio:

Now, how would you go along to arrive at that by feature based testing? 
I can't even start to imagine.

Secondly, we *do* have some "feature based tests". But I'd rather get 
rid of them, because they behave (and typically are) more like 
workarounds. Look at this code, for instance.

   # Check for broken SuSE 'ld' for which 'Only anonymous version tag is 
allowed in executable.'
   if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$GCC" = xyes; then
     AC_MSG_CHECKING([for broken SuSE 'ld' which only understands 
anonymous version tags in executables])
     echo "SUNWprivate_1.1 { local: *; };" >
     echo "int main() { }" > main.c
     if $CXX -Xlinker main.c 
     rm -rf main.c

It's probably a very good example of what feature based tests would look 
like. I'd be horrified if we were do that for all flags. The build 
system would blow up tenfold in size and complexity, for no or little gain.


More information about the build-dev mailing list