changeset 621:2536413edfd8

test/resolve_self: hack for linkers not having --export-dynamic
author Tassilo Philipp
date Wed, 05 Oct 2022 11:49:41 +0200
parents 14c582c828b9
children e30f3a5453d4
files test/resolve_self/CMakeLists.txt test/resolve_self/Makefile.embedded test/resolve_self/Makefile.generic
diffstat 3 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/resolve_self/CMakeLists.txt	Mon Oct 03 16:52:15 2022 +0200
+++ b/test/resolve_self/CMakeLists.txt	Wed Oct 05 11:49:41 2022 +0200
@@ -1,3 +1,4 @@
 add_executable(resolve_self main.c)
 target_link_libraries(resolve_self dynload_s)
+set_target_properties(resolve_self PROPERTIES ENABLE_EXPORTS on)
 
--- a/test/resolve_self/Makefile.embedded	Mon Oct 03 16:52:15 2022 +0200
+++ b/test/resolve_self/Makefile.embedded	Wed Oct 05 11:49:41 2022 +0200
@@ -11,7 +11,11 @@
 .PHONY: all clean install
 
 ${APP}: ${OBJS} 
-	${CC} ${OBJS} ${LDFLAGS} ${LDLIBS} -o ${APP} 
+	# some linkers (e.g. older apple mach-o linkers) don't know
+	# --export-dynamic, so try without if link fails; this is a bit hacky and
+	#  should prob be part of of the ./configure run
+	${CC} ${CFLAGS} ${LDFLAGS} -Wl,--export-dynamic ${OBJS} ${LDLIBS_D} ${LDLIBS} -o ${APP} || \
+		${CC} ${CFLAGS} ${LDFLAGS} ${OBJS} ${LDLIBS_D} ${LDLIBS} -o ${APP}
 
 clean:
 	rm -f ${APP} ${OBJS}
--- a/test/resolve_self/Makefile.generic	Mon Oct 03 16:52:15 2022 +0200
+++ b/test/resolve_self/Makefile.generic	Wed Oct 05 11:49:41 2022 +0200
@@ -3,12 +3,15 @@
 SRCTOP    = ${VPATH}/../..
 BLDTOP    = ../..
 CFLAGS   += -I${SRCTOP}/dynload
-LDFLAGS  += -Wl,--export-dynamic
 LDLIBS_D  = -L${BLDTOP}/dynload -ldynload_s 
 .PHONY: all clean install
 all: ${APP}
 ${APP}: ${OBJS} 
-	${CC} ${CFLAGS} ${LDFLAGS} ${OBJS} ${LDLIBS_D} ${LDLIBS} -o ${APP}
+	# some linkers (e.g. apple's mach-o linker) don't know --export-dynamic, so
+	# try without if link fails; this is a bit hacky and should prob be part of
+	# of the ./configure run
+	${CC} ${CFLAGS} ${LDFLAGS} -Wl,--export-dynamic ${OBJS} ${LDLIBS_D} ${LDLIBS} -o ${APP} || \
+		${CC} ${CFLAGS} ${LDFLAGS} ${OBJS} ${LDLIBS_D} ${LDLIBS} -o ${APP}
 clean:
 	rm -f ${APP} ${OBJS}
 install: