Skip to content

Commit 5f793be

Browse files
committed
autotools: Link with --undefined-version
1 parent 641428a commit 5f793be

File tree

6 files changed

+191
-2
lines changed

6 files changed

+191
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ libxslt.spec
3636
libxslt.spec.in.orig
3737
libxslt/xsltconfig.h
3838
ltmain.sh
39-
m4/
39+
m4/libtool*
40+
m4/lt*
4041
missing
4142
py-compile
4243
python/gen_prog

configure.ac

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ dnl
9595
AC_MSG_CHECKING([how to pass version script to the linker ($LD)])
9696
VERSION_SCRIPT_FLAGS=none
9797
if $LD --help 2>&1 | grep "version-script" >/dev/null 2>/dev/null; then
98-
VERSION_SCRIPT_FLAGS=-Wl,--version-script=
98+
dnl lld 16 defaults to --no-undefined-version but the version script
99+
dnl can contain symbols disabled by configuration options.
100+
VERSION_SCRIPT_FLAGS=''
101+
AX_APPEND_LINK_FLAGS([-Wl,--undefined-version], [VERSION_SCRIPT_FLAGS])
102+
AX_APPEND_FLAG([-Wl,--version-script=], [VERSION_SCRIPT_FLAGS])
99103
elif $LD --help 2>&1 | grep "M mapfile" >/dev/null 2>/dev/null; then
100104
VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
101105
fi

m4/ax_append_flag.m4

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
8+
#
9+
# DESCRIPTION
10+
#
11+
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
12+
# added in between.
13+
#
14+
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15+
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
16+
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
17+
# FLAG.
18+
#
19+
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
20+
#
21+
# LICENSE
22+
#
23+
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
24+
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
25+
#
26+
# Copying and distribution of this file, with or without modification, are
27+
# permitted in any medium without royalty provided the copyright notice
28+
# and this notice are preserved. This file is offered as-is, without any
29+
# warranty.
30+
31+
#serial 8
32+
33+
AC_DEFUN([AX_APPEND_FLAG],
34+
[dnl
35+
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
36+
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
37+
AS_VAR_SET_IF(FLAGS,[
38+
AS_CASE([" AS_VAR_GET(FLAGS) "],
39+
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
40+
[
41+
AS_VAR_APPEND(FLAGS,[" $1"])
42+
AC_RUN_LOG([: FLAGS="$FLAGS"])
43+
])
44+
],
45+
[
46+
AS_VAR_SET(FLAGS,[$1])
47+
AC_RUN_LOG([: FLAGS="$FLAGS"])
48+
])
49+
AS_VAR_POPDEF([FLAGS])dnl
50+
])dnl AX_APPEND_FLAG

m4/ax_append_link_flags.m4

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8+
#
9+
# DESCRIPTION
10+
#
11+
# For every FLAG1, FLAG2 it is checked whether the linker works with the
12+
# flag. If it does, the flag is added FLAGS-VARIABLE
13+
#
14+
# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
15+
# used. During the check the flag is always added to the linker's flags.
16+
#
17+
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
18+
# when the check is done. The check is thus made with the flags: "LDFLAGS
19+
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20+
# issue an error when a bad flag is given.
21+
#
22+
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
23+
#
24+
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
25+
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
26+
#
27+
# LICENSE
28+
#
29+
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
30+
#
31+
# Copying and distribution of this file, with or without modification, are
32+
# permitted in any medium without royalty provided the copyright notice
33+
# and this notice are preserved. This file is offered as-is, without any
34+
# warranty.
35+
36+
#serial 7
37+
38+
AC_DEFUN([AX_APPEND_LINK_FLAGS],
39+
[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
40+
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
41+
for flag in $1; do
42+
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
43+
done
44+
])dnl AX_APPEND_LINK_FLAGS

m4/ax_check_link_flag.m4

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8+
#
9+
# DESCRIPTION
10+
#
11+
# Check whether the given FLAG works with the linker or gives an error.
12+
# (Warnings, however, are ignored)
13+
#
14+
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15+
# success/failure.
16+
#
17+
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
18+
# when the check is done. The check is thus made with the flags: "LDFLAGS
19+
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20+
# issue an error when a bad flag is given.
21+
#
22+
# INPUT gives an alternative input source to AC_LINK_IFELSE.
23+
#
24+
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25+
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26+
#
27+
# LICENSE
28+
#
29+
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
30+
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
31+
#
32+
# Copying and distribution of this file, with or without modification, are
33+
# permitted in any medium without royalty provided the copyright notice
34+
# and this notice are preserved. This file is offered as-is, without any
35+
# warranty.
36+
37+
#serial 6
38+
39+
AC_DEFUN([AX_CHECK_LINK_FLAG],
40+
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41+
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
42+
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
43+
ax_check_save_flags=$LDFLAGS
44+
LDFLAGS="$LDFLAGS $4 $1"
45+
AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46+
[AS_VAR_SET(CACHEVAR,[yes])],
47+
[AS_VAR_SET(CACHEVAR,[no])])
48+
LDFLAGS=$ax_check_save_flags])
49+
AS_VAR_IF(CACHEVAR,yes,
50+
[m4_default([$2], :)],
51+
[m4_default([$3], :)])
52+
AS_VAR_POPDEF([CACHEVAR])dnl
53+
])dnl AX_CHECK_LINK_FLAGS

m4/ax_require_defined.m4

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_REQUIRE_DEFINED(MACRO)
8+
#
9+
# DESCRIPTION
10+
#
11+
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
12+
# been defined and thus are available for use. This avoids random issues
13+
# where a macro isn't expanded. Instead the configure script emits a
14+
# non-fatal:
15+
#
16+
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
17+
#
18+
# It's like AC_REQUIRE except it doesn't expand the required macro.
19+
#
20+
# Here's an example:
21+
#
22+
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
23+
#
24+
# LICENSE
25+
#
26+
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
27+
#
28+
# Copying and distribution of this file, with or without modification, are
29+
# permitted in any medium without royalty provided the copyright notice
30+
# and this notice are preserved. This file is offered as-is, without any
31+
# warranty.
32+
33+
#serial 2
34+
35+
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
36+
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
37+
])dnl AX_REQUIRE_DEFINED

0 commit comments

Comments
 (0)