From 37115452e8d06f977c28318479d5d99bd7062891 Mon Sep 17 00:00:00 2001 From: Giuliano Belinassi Date: Wed, 24 Jul 2024 18:26:28 -0300 Subject: [PATCH] Workaround bug in autoconf 2.69 Autoconf 2.69 does not expand the $(target_cpu) variable when creating directories, hence we have to do things manually. Also it doesn't seems to like the @VAR@ variable replacements. Signed-off-by: Giuliano Belinassi --- configure.ac | 20 ++++++++++++-------- include/Makefile.am | 11 +++++++++++ lib/Makefile.am | 28 +++++++++++++++++++++++----- tests/Makefile.am | 12 +++++++++++- tools/Makefile.am | 14 ++++++++++++-- 5 files changed, 69 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 87a30676..a1f2cdc5 100644 --- a/configure.ac +++ b/configure.ac @@ -226,16 +226,21 @@ AC_SUBST([PAGE_SIZE], [$($GETCONF PAGE_SIZE)])) _NOPS_LEN=0 _PRE_NOPS_LEN=0 -AS_CASE([$host_cpu], +_LD_LINUX="" +AS_CASE([$target_cpu], [x86_64], [ _NOPS_LEN=16 _PRE_NOPS_LEN=14 + _LD_LINUX="ld-linux-x86-64.so.2" + _PROC="x86_64" ], [powerpc64le], [ _NOPS_LEN=19 _PRE_NOPS_LEN=18 + _LD_LINUX="ld64.so.2" + _PROC="powerpc64le" ] ) @@ -247,15 +252,14 @@ AC_DEFINE_UNQUOTED([ULP_NOPS_LEN], [$ULP_NOPS_LEN], AC_DEFINE_UNQUOTED([PRE_NOPS_LEN], [$PRE_NOPS_LEN], [Padding nops before the entry point of functions]) -_LD_LINUX="" -AC_CHECK_FILE("/usr/lib64/ld-linux-x86-64.so.2", - AC_SUBST([_LD_LINUX], "ld-linux-x86-64.so.2")) -AC_CHECK_FILE("/usr/lib64/ld64.so.2", - AC_SUBST([_LD_LINUX], "ld64.so.2")) +AC_DEFINE_UNQUOTED([LD_LINUX], ["$_LD_LINUX"], +[Path to the ld-linux loader] ) -AC_DEFINE_UNQUOTED([LD_LINUX], ["$_LD_LINUX"], [Path to the ld-linux loader] ) +# Workaround a bug in autoconf 2.69 +AM_CONDITIONAL([CPU_X86_64], [test "$_PROC" == "x86_64"]) +AM_CONDITIONAL([CPU_PPC64LE], [test "$_PROC" == "powerpc64le"]) -# Check if -fpatchable-function-entry=$ULP_NOPS_LEN,$PRE_NOPS_LEN works +# Check if -fpatchable-function-entry=$ULP_NOPS_LEN,$RE_NOPS_LEN works # correctly. AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[extern void g(void); diff --git a/include/Makefile.am b/include/Makefile.am index 6bf95980..98a1dcb3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -28,3 +28,14 @@ noinst_HEADERS = \ ld_rtld.h \ insn_queue.h \ insn_queue_lib.h + +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +noinst_HEADERS += \ + arch/x86_64/arch_common.h +endif + +if CPU_PPC64LE +noinst_HEADERS += \ + arch/powerpc64le/arch_common.h +endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 483717bc..77b64c7c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -24,17 +24,35 @@ libpulp_la_SOURCES = \ interpose.c \ msg_queue.c \ insn_queue.c \ - error.c \ - arch/$(target_cpu)/ulp_interface.S \ - arch/$(target_cpu)/patch.c -libpulp_la_DEPENDENCIES= libpulp.versions + error.c + libpulp_la_LDFLAGS = \ -ldl \ - -l:@_LD_LINUX@ \ -Wl,--version-script=$(srcdir)/libpulp.versions \ -Wl,--hash-style=sysv \ # Ubuntu seems to default to gnu, so be clear we ... $(AM_LDFLAGS) # ... want old style hash sections, else DT_HASH is empty. +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +libpulp_la_SOURCES += \ + arch/x86_64/ulp_interface.S \ + arch/x86_64/patch.c + +libpulp_la_LDFLAGS += \ + -l:ld-linux-x86-64.so.2 +endif + +if CPU_PPC64LE +libpulp_la_SOURCES += \ + arch/powerpc64le/ulp_interface.S \ + arch/powerpc64le/patch.c + +libpulp_la_LDFLAGS += \ + -l:ld64.so.2 +endif + +libpulp_la_DEPENDENCIES= libpulp.versions + libpulp_la_LIBADD = $(top_builddir)/common/libcommon.la AM_CFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/include/arch/$(target_cpu) diff --git a/tests/Makefile.am b/tests/Makefile.am index d9f6efa5..50376634 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -560,9 +560,19 @@ manyprocesses_LDADD = libmanyprocesses.la manyprocesses_DEPENDENCIES = $(POST_PROCESS) $(METADATA) dlsym_SOURCES = dlsym.c -dlsym_LDADD = -lpthread -ldl -lrt -l:@_LD_LINUX@ +dlsym_LDADD = -lpthread -ldl -lrt dlsym_DEPENDENCIES = $(POST_PROCESS) $(METADATA) +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +dlsym_LDADD += \ + -l:ld-linux-x86-64.so.2 +endif +if CPU_PPC64LE +dlsym_LDADD += \ + -l:ld64.so.2 +endif + stress_SOURCES = stress.c stress_LDADD = libstress.la stress_DEPENDENCIES = $(POST_PROCESS) $(METADATA) diff --git a/tools/Makefile.am b/tools/Makefile.am index faa074fb..0637e034 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -55,8 +55,18 @@ ulp_SOURCES = \ pcqueue.c \ extract.c \ set_patchable.c \ - insn_queue.c \ - arch/$(target_cpu)/post-arch.c + insn_queue.c + +# Workaround a bug in Autoconf 2.69 +if CPU_X86_64 +ulp_SOURCES += \ + arch/x86_64/post-arch.c +endif + +if CPU_PPC64LE +ulp_SOURCES += \ + arch/powerpc64le/post-arch.c +endif ulp_LDADD = $(top_builddir)/common/libcommon.la -lelf -ljson-c -lpthread -ldl $(LIBUNWIND_LIBS)