On 08/10/2024 18:31, Kun Yang wrote:
Greetings,

I'm intended to update libtool package for MSYS2, but some troubles occurred
that beyond my ability. I'm confused by some flags when linking.

Compared to v2.4.7, libtool now accepts more flags when linking. The most of the
flags in
https://github.com/msys2/MSYS2-packages/blob/master/libtool/0003-Pass- various-runtime-library-flags-to-GCC.mingw.patch were added in v2.5.3. As you can see, there is still some flags automatically ignored by libtool when linking. For example, you can run the following commands
in your shell.

libtool --version | head -1
echo "void foo(void) {}" >foo.c
libtool --mode=compile --tag=CC cc -c foo.c -o foo.lo -O3 -ffast-math
libtool --mode=link --tag=CC cc foo.lo -o libfoo.la -O3 -ffast-math -rpath
/usr/lib -version-info 0 -no-undefined

Here is the output on Arch Linux with libtool v2.5.3 (they prefer uses git
instead of the unstable version, so -dirty were append in the version string)

libtool (GNU libtool) 2.5.3-dirty
libtool: compile: cc -c foo.c -O3 -ffast-math -fPIC -DPIC -o .libs/foo.o
libtool: compile: cc -c foo.c -O3 -ffast-math -o foo.o >/dev/null 2>&1
libtool: link: rm -fr .libs/libfoo.a .libs/libfoo.la .libs/libfoo.lai
.libs/libfoo.so .libs/libfoo.so.0 .libs/libfoo.so.0.0.0 libtool: link: gcc
-shared -fPIC -DPIC .libs/foo.o -O3 -Wl,-soname -Wl,libfoo.so.0 -o
.libs/libfoo.so.0.0.0 libtool: link: (cd ".libs" && rm -f "libfoo.so.0" && ln -s "libfoo.so.0.0.0" "libfoo.so.0") libtool: link: (cd ".libs" && rm -f "libfoo.so"
&& ln -s "libfoo.so.0.0.0" "libfoo.so") libtool: link: ar cr .libs/libfoo.a
foo.o libtool: link: ranlib .libs/libfoo.a libtool: link: ( cd ".libs" && rm -f
"libfoo.la" && ln -s "../libfoo.la" "libfoo.la" )

As what you saw, -ffast-math were ignored. However, I found that some flags were necessary on some platforms to generate startup code for these flags. See the
footnote in the following page.
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#FOOT1

Is there any reason why these flags not included?

Flags are added here to pass through at link time instead of being
stripped, so if '-ffastmath' is necessary for linking, it can be added
with a comment above to provide reasoning.

Is it necessary for linking?

-ffast-math is an optimization option. I assume it is not necessary for
linking, but I may be wrong.

If so, could anyone please give me a full list of these flags which are probably necessary for linking?

If the options listed here [1] are needed, I would be happy to accept a
patch for them with the listed rationale for why these flags should be
passed through unchanged.

[1] https://github.com/msys2/MSYS2-packages/blob/master/libtool/0003-Pass-various-runtime-library-flags-to-GCC.mingw.patch

--
Ileana Dumitrescu

GPG Public Key: FA26 CA78 4BE1 8892 7F22 B99F 6570 EA01 146F 7354

Attachment: OpenPGP_0x6570EA01146F7354.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to