diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-15 08:17:33 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-15 08:17:33 +0200 |
commit | 90d7bfe9cfe172baac2f96e2373ae98efff6d25a (patch) | |
tree | 6a766f1f9bab63dc8c453b2c48ee1bb1e10a0110 | |
parent | 15539c0af43cc63d99239e3b65d936955cde3226 (diff) | |
download | ghdl-90d7bfe9cfe172baac2f96e2373ae98efff6d25a.tar.gz ghdl-90d7bfe9cfe172baac2f96e2373ae98efff6d25a.tar.bz2 ghdl-90d7bfe9cfe172baac2f96e2373ae98efff6d25a.zip |
Automatically add -Wl,-u,ghdl_main when -shared is used. For #640
-rw-r--r-- | Makefile.in | 9 | ||||
-rw-r--r-- | src/ghdldrv/ghdldrv.adb | 4 | ||||
-rw-r--r-- | src/grt/Makefile.inc | 26 |
3 files changed, 31 insertions, 8 deletions
diff --git a/Makefile.in b/Makefile.in index 4c8f599d9..7749d58e3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -455,10 +455,16 @@ ghwlib.o: $(srcdir)/src/grt/ghwlib.c $(srcdir)/src/grt/ghwlib.h ############### grt ##################################################### -install.grt: $(libdirsuffix)/libgrt.a $(libdirsuffix)/grt.lst $(libdirsuffix)/grt-exec.lst install.dirs +install.grt: \ + $(libdirsuffix)/libgrt.a \ + $(libdirsuffix)/grt.lst \ + $(libdirsuffix)/grt-exec.lst \ + $(libdirsuffix)/grt-shared.lst \ + install.dirs $(INSTALL_DATA) $(libdirsuffix)/libgrt.a $(DESTDIR)$(VHDL_LIB_DIR)/libgrt.a $(INSTALL_DATA) $(libdirsuffix)/grt.lst $(DESTDIR)$(VHDL_LIB_DIR)/grt.lst $(INSTALL_DATA) $(libdirsuffix)/grt-exec.lst $(DESTDIR)$(VHDL_LIB_DIR)/grt-exec.lst + $(INSTALL_DATA) $(libdirsuffix)/grt-shared.lst $(DESTDIR)$(VHDL_LIB_DIR)/grt-shared.lst $(INSTALL_DATA) $(GRTSRCDIR)/grt.ver $(DESTDIR)$(VHDL_LIB_DIR)/grt.ver test "x$(LIBBACKTRACE)" = x || test "x$(backend)" = xgcc || \ $(INSTALL_DATA) $(LIBBACKTRACE) $(DESTDIR)$(VHDL_LIB_DIR)/libbacktrace.a @@ -467,6 +473,7 @@ uninstall.grt: $(RM) $(DESTDIR)$(VHDL_LIB_DIR)/libgrt.a $(RM) $(DESTDIR)$(VHDL_LIB_DIR)/grt.lst $(RM) $(DESTDIR)$(VHDL_LIB_DIR)/grt-exec.lst + $(RM) $(DESTDIR)$(VHDL_LIB_DIR)/grt-shared.lst $(RM) $(DESTDIR)$(VHDL_LIB_DIR)/grt.ver $(RM) $(DESTDIR)$(VHDL_LIB_DIR)/libbacktrace.a diff --git a/src/ghdldrv/ghdldrv.adb b/src/ghdldrv/ghdldrv.adb index c0a9e2b6f..90a64dc54 100644 --- a/src/ghdldrv/ghdldrv.adb +++ b/src/ghdldrv/ghdldrv.adb @@ -1054,7 +1054,9 @@ package body Ghdldrv is end if; Last_File := Filelist.Last; Add_Lib_File_List ("grt"); - if not Cmd.Flag_Shared then + if Cmd.Flag_Shared then + Add_Lib_File_List ("grt-shared"); + else Add_Lib_File_List ("grt-exec"); end if; diff --git a/src/grt/Makefile.inc b/src/grt/Makefile.inc index 3c37dc829..b3b9628e3 100644 --- a/src/grt/Makefile.inc +++ b/src/grt/Makefile.inc @@ -44,9 +44,10 @@ else osys:=$(word 3,$(targ)) endif -GRT_ELF_OPTS:=-Wl,--version-script=@/grt.ver -Wl,--export-dynamic +# Standard GRT_EXEC_OPTS value for ELF platforms. +GRT_ELF_EXEC_OPTS:=-Wl,--version-script=@/grt.ver -Wl,--export-dynamic -# These conditions define 3 variables: +# These conditions define these variables: # GRT_TARGET_OBJS: platform specific files to be added in the grt library # GRT_EXTRA_LIBS: platform specific libraries and options to be added during # link of simulation binaries. These are library used by grt. @@ -54,12 +55,14 @@ GRT_ELF_OPTS:=-Wl,--version-script=@/grt.ver -Wl,--export-dynamic # simulation binaries, but not needed when creating a shared library. # It is set on ELF platforms to export some symbols (like the vpi # functions) so that a vpi object file can refer them. -# Set target files. +# GRT_SHARED_OPTS: platform specific options to be added during link of +# -shared simulation binaries. Used instead of GET_EXEC_OPTS ifeq ($(filter-out mingw32 mingw64,$(osys)),) # For windows. GRT_TARGET_OBJS=win32.o clock.o GRT_EXTRA_LIB=-ldbghelp GRT_EXEC_OPTS= + GRT_SHARED_OPTS=-Wl,-u,_ghdl_main else # For unix variants. # Usually needs -dl (for dlopen) and -lm (for math functions). @@ -67,19 +70,21 @@ else GRT_TARGET_OBJS=jumps.o times.o GRT_EXTRA_LIB= GRT_EXEC_OPTS= + GRT_SHARED_OPTS=-Wl,-u,ghdl_main ifeq ($(filter-out linux%,$(osys)),) GRT_EXTRA_LIB=-ldl -lm - GRT_EXEC_OPTS=$(GRT_ELF_OPTS) + GRT_EXEC_OPTS=$(GRT_ELF_EXEC_OPTS) endif ifeq ($(filter-out netbsd freebsd% dragonfly%,$(osys)),) GRT_EXTRA_LIB=-lm - GRT_EXEC_OPTS=$(GRT_ELF_OPTS) + GRT_EXEC_OPTS=$(GRT_ELF_EXEC_OPTS) endif ifeq ($(filter-out solaris%,$(osys)),) GRT_EXTRA_LIB=-ldl -lm endif ifeq ($(filter-out darwin%,$(osys)),) + GRT_SHARED_OPTS=-Wl,-u,_ghdl_main GRT_EXTRA_LIB= endif endif @@ -120,7 +125,12 @@ GRT_PRAGMA_FLAG=-gnatec$(GRTSRCDIR)/grt.adc -gnatdY # Rule to compile an Ada file. GRT_ADACOMPILE=$(GNATMAKE) -u -c $(GRT_FLAGS) $(GRT_PRAGMA_FLAG) -grt-all: $(libdirsuffix)/libgrt.a $(libdirsuffix)/$(GRT_LIBBACKTRACE) $(libdirsuffix)/grt.lst $(libdirsuffix)/grt-exec.lst $(libdirsuffix)/grt.ver +grt-all: $(libdirsuffix)/libgrt.a \ + $(libdirsuffix)/$(GRT_LIBBACKTRACE) \ + $(libdirsuffix)/grt.lst \ + $(libdirsuffix)/grt-exec.lst \ + $(libdirsuffix)/grt-shared.lst \ + $(libdirsuffix)/grt.ver $(libdirsuffix)/libgrt.a: $(GRT_ADD_OBJS) grt/run-bind.o grt/main.o grt/grt-files $(RM) -f $@ @@ -257,6 +267,10 @@ $(libdirsuffix)/grt-exec.lst: echo "# link options for executables" > $@ for i in $(GRT_EXEC_OPTS); do echo $$i >> $@; done +$(libdirsuffix)/grt-shared.lst: + echo "# link options for shared libraries" > $@ + for i in $(GRT_SHARED_OPTS); do echo $$i >> $@; done + $(libdirsuffix)/grt.ver: $(GRTSRCDIR)/grt.ver cp $< $@ |