[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C library promoted to C++ linkage due to optional C++ source module
From: |
Bob Friesenhahn |
Subject: |
Re: C library promoted to C++ linkage due to optional C++ source module |
Date: |
Sat, 9 Mar 2024 17:23:33 -0600 |
User-agent: |
Mozilla Thunderbird |
Hi Bob,
It is my opinion that if a library or program
is linked with C++ libraries (and especially if it is a static build!)
that it should be linked using the C++ linker. Likewise, if a library
or program does not depend on, or contain any C++ code, it should be
linked with the C linker.
I surely agree, in principle. But that doesn't mean I have the faintest
idea what to change in Automake to make that be the case. You probably
know better than me :). Can you provide (as simple as possible) test cases?
I have since backed away from this approach because I saw that the
clever way that Automake handles conditionals is not going to be smart
enough to make language decisions based on if a file is added or
removed. The compiler/linker type to use is already baked into
Makefile.in and the choice used is also based on the optional source
files. If a C++ file appears, the language is promoted from C to C++
(--tag=CXX) and is baked into Makefile.in.
I see code like this appearing in Makefile.in:
Magick___lib_libGraphicsMagick___la_LINK = $(LIBTOOL) $(AM_V_lt) \
--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(Magick___lib_libGraphicsMagick___la_LDFLAGS) $(LDFLAGS) -o \
$@
As such, it seems that this would be a major feature request and
significant redesign, and is not a simple bug.
I may be possible to replace this Makefile hunk as an override, but it
may not be reliable.
It does seem important to link with the C++ compiler when depending on
C++ libraries, but modern Linux apparently works "fine" if you don't.
I have a continuing problem that when libtool tests
bug-libtool@gnu.org for that one, I think ... --best, karl.
There is a bug open already in libtool for the issue with dropping -lm
when mixing C and C++. It is not clear that the C++ linker provides -lm
by default since it seemed to be pulled in by implicit dependencies as
part of the libraries implementation.
Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt