diff options
author | Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> | 2022-12-15 10:43:37 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-12-31 15:49:04 +0000 |
commit | ebc41f9a817dbae01c7450cd33c1968318ce8df0 (patch) | |
tree | 8f68b88f815128f24f9a12aebafb6de2448bf9f0 /gcc | |
parent | 0e8c946508f4515ef9d92a3b9156283d1295b760 (diff) | |
download | gcc-ebc41f9a817dbae01c7450cd33c1968318ce8df0.zip gcc-ebc41f9a817dbae01c7450cd33c1968318ce8df0.tar.gz gcc-ebc41f9a817dbae01c7450cd33c1968318ce8df0.tar.bz2 |
modula-2: Fix building the plugin for Darwin [PR107612].
* Makes the configured value for INCINTL available as a variable so that
it can be used in language makefile fragements. It is then used in the m2
fragment to make the include path available to the plugin compile.
* Updates the DSO suffix to use .dylib for Darwin.
* Adds '-Wl,-undefined,dynamic_lookup' to the link flags so that symbols can
be resolved at runtime.
* Removes the extraneous $(exeext) from the DSO names.
Since the linking is driven by CXX, we also need to supress the addition of
default libraries otherwise:
(1) we will get a reference to an uninstalled libstdc++
(2) the process opening the plugin would have two instances 0f libstdc++ -
one statically linked into gm2 and one dynamically linked into the plugin.
PR modula2/107612
gcc/ChangeLog:
* Makefile.in: Make the configured libintl includes avaiable in INCINTL.
(BUILD_CPPFLAGS): Use INCINTL.
gcc/m2/ChangeLog:
* Make-lang.in (soext): Use .dylib for Darwin.
(PLUGINLDFLAGS): Use dynmic lookup, set the plugin name, and append
-nodefaultlibs to suppress the linking of libstdc++.
Use INCINTL in compile lines for the plugin.
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/Makefile.in | 5 | ||||
-rw-r--r-- | gcc/m2/Make-lang.in | 34 |
2 files changed, 26 insertions, 13 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 995d77f..4e5fb67 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -729,6 +729,7 @@ htmldir = @htmldir@ USE_NLS = @USE_NLS@ # Internationalization library. +INCINTL = @INCINTL@ LIBINTL = @LIBINTL@ LIBINTL_DEP = @LIBINTL_DEP@ @@ -820,7 +821,7 @@ BUILD_LINKERFLAGS = $(BUILD_CXXFLAGS) # Native linker and preprocessor flags. For x-fragment overrides. BUILD_LDFLAGS=@BUILD_LDFLAGS@ BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ - -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS) + -I$(srcdir)/../include $(INCINTL) $(CPPINC) $(CPPFLAGS) # Actual name to use when installing a native compiler. GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)') @@ -1125,7 +1126,7 @@ BUILD_ERRORS = build/errors.o # currently being compiled, in both source trees, to be examined as well. # libintl.h will be found in ../intl if we are using the included libintl. INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ - -I$(srcdir)/../include @INCINTL@ \ + -I$(srcdir)/../include $(INCINTL) \ $(CPPINC) $(CODYINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \ $(ISLINC) diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index a8bd7fe..3050f5a 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -31,6 +31,16 @@ GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ -L$(objdir)/../ld $(TFLAGS) +# FIXME: Get from gcc-plugin.m4 instead of hardcoding. +ifeq (,$(findstring darwin,$(host))) + soext=.so +else + soext=.dylib + PLUGINLDFLAGS = -Wl,-undefined,dynamic_lookup + PLUGINLDFLAGS += -Wl,-install_name,m2rte$(soext) + PLUGINLDFLAGS += -nodefaultlibs +endif + TEXISRC = $(objdir)/m2/images/gnu.eps \ $(srcdir)/doc/gm2.texi \ m2/gm2-libs.texi \ @@ -114,9 +124,9 @@ po-generated: # Build hooks: -m2.all.cross: gm2-cross$(exeext) plugin/m2rte$(exeext).so +m2.all.cross: gm2-cross$(exeext) plugin/m2rte$(soext) -m2.start.encap: gm2$(exeext) plugin/m2rte$(exeext).so +m2.start.encap: gm2$(exeext) plugin/m2rte$(soext) m2.rest.encap: @@ -403,14 +413,16 @@ m2.uninstall: m2.install-plugin: installdirs $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir) - $(INSTALL_PROGRAM) plugin/m2rte$(exeext).so $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so - chmod a+x $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so + $(INSTALL_PROGRAM) plugin/m2rte$(soext) $(DESTDIR)$(plugin_resourcesdir)/m2rte$(soext) + chmod a+x $(DESTDIR)$(plugin_resourcesdir)/m2rte$(soext) + +override PLUGINCFLAGS := $(filter-out -mdynamic-no-pic,$(PLUGINCFLAGS)) -plugin/m2rte$(exeext).so: $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \ +plugin/m2rte$(soext): $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \ insn-attr-common.h insn-flags.h $(generated_files) test -d plugin || mkdir plugin - $(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc - $(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLIBS) -fno-rtti plugin/m2rte.o -shared -o $@ + $(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) $(INCINTL) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc + $(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLDFLAGS) $(PLUGINLIBS) $(LIBINTL) -fno-rtti plugin/m2rte.o -shared -o $@ # Clean hooks: @@ -526,7 +538,7 @@ cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) $(m2.prev) stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \ - m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o + m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) m2/gm2-libs-boot/M2LINK.o @$(call LINK_PROGRESS,$(INDEX.m2),start) +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \ attribs.o \ @@ -538,7 +550,7 @@ stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $( stage1/m2/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \ $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \ $(GM2_LIBS_BOOT) $(MC_LIBS) \ - m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so \ + m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \ m2/gm2-libs-boot/M2LINK.o \ $(m2.prev) @$(call LINK_PROGRESS,$(INDEX.m2),start) @@ -572,7 +584,7 @@ m2/gm2-gcc/m2configure.o: $(srcdir)/m2/gm2-gcc/m2configure.cc \ -c $(srcdir)/m2/gm2-gcc/m2configure.cc $(OUTPUT_OPTION) m2/gm2-lang.o: $(srcdir)/m2/gm2-lang.cc gt-m2-gm2-lang.h $(GCC_HEADER_DEPENDENCIES_FOR_M2) - $(COMPILER) -c -g -I$(GM2GCC) $(ALL_COMPILERFLAGS) \ + $(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) m2/stor-layout.o: $(srcdir)/stor-layout.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) @@ -585,7 +597,7 @@ m2/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) m2/gm2-gcc/rtegraph.o: $(srcdir)/m2/gm2-gcc/rtegraph.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \ gt-m2-rtegraph.h - $(COMPILER) -c -g -I$(GM2GCC) $(ALL_COMPILERFLAGS) \ + $(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) c-family/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) |