From 9103ac7e08352297be5ab35c7d5a3d734384e8f8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 4 Mar 2022 12:22:45 +0100 Subject: [PATCH] buildsys: change gac to not use libtool --- Makefile.rules | 73 ++++++++++++++++++++++++++++++++++----------- cnf/gac.in | 63 ++++++++++++-------------------------- configure.ac | 1 - etc/Makefile.gappkg | 22 +++++--------- 4 files changed, 83 insertions(+), 76 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index 24fa4452336..53313bc3ae8 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -229,17 +229,21 @@ SYSINFO_CFLAGS += $(CFLAGS) # C++ compiler flags ######################################################################## GAP_CXXFLAGS = $(ABI_CFLAGS) +SYSINFO_CXXFLAGS = $(ABI_CFLAGS) GAP_CXXFLAGS += $(PTHREAD_CFLAGS) +SYSINFO_CXXFLAGS += $(PTHREAD_CFLAGS) # Finally add user provided CXXFLAGS GAP_CXXFLAGS += $(CXXFLAGS) +SYSINFO_CXXFLAGS += $(CXXFLAGS) ######################################################################## # Linker flags ######################################################################## GAP_LDFLAGS = $(ABI_CFLAGS) +SYSINFO_LDFLAGS = $(ABI_CFLAGS) # Add flags for dependencies GAP_LDFLAGS += $(GMP_LDFLAGS) @@ -253,10 +257,12 @@ GAP_LDFLAGS += $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) # Finally add user provided flags GAP_LDFLAGS += $(LDFLAGS) +SYSINFO_LDFLAGS += $(LDFLAGS) # libs GAP_LIBS = +SYSINFO_LIBS = # Add flags for dependencies GAP_LIBS += $(GMP_LIBS) @@ -268,6 +274,46 @@ GAP_LIBS += $(LIBATOMIC_OPS_LIBS) # Finally add user provided flags GAP_LIBS += $(LIBS) +SYSINFO_LIBS += $(LIBS) + + +######################################################################## +# gac flags +######################################################################## + +# +# Determine flags for building kernel extensions for use in GAC +# +# For now we basically support GCC and clang, on Linux/macOS/Windows, +# and as a side effect also some other systems such as FreeBSD. +# Support for other compilers or operating systems will require some +# extra tweaks. +# +ifneq (,$(findstring cygwin,$(host_os))) + GAC_CFLAGS = + GAC_LDFLAGS = -shared -Wl,$(abs_builddir)/bin/$(GAPARCH)/gap.dll + # Note: the above won't be correct after "make install"; but then I am not + # sure we care about "make install" on Cygwin, so I am not going to work on + # this until someone specifically asks for it (and even then I'll require + # that person to help test it) +else + ifneq (,$(findstring darwin,$(host_os))) + GAC_CFLAGS = -fno-common + GAC_LDFLAGS = -bundle -bundle_loader $(SYSINFO_GAP) + else + GAC_CFLAGS = -fPIC + GAC_LDFLAGS = -shared + endif +endif + + +######################################################################## +# additional settings for use in sysinfo.gap +######################################################################## + +# paths to gap and gac executable +SYSINFO_GAP = $(abs_builddir)/gap +SYSINFO_GAC = $(abs_builddir)/gac ######################################################################## @@ -543,10 +589,8 @@ install-bin: gap echo "$$gap_wrapper" > $(DESTDIR)$(bindir)/gap chmod 0755 $(DESTDIR)$(bindir)/gap - # TODO: make gac installable; this requires adjusting path in it, and - # installing the libtool script generated by configure somewhere; and then - # putting that path to it into gac) - #$(INSTALL) gac $(DESTDIR)$(bindir) + sed -e "s;@SYSINFO_GAPROOT@;$(libdir)/gap;" < $(srcdir)/cnf/gac.in > $(DESTDIR)$(bindir)/gac + chmod 0755 $(DESTDIR)$(bindir)/gac install-doc: # TODO: should this depend on the 'doc' target? but that target is phony @@ -791,16 +835,6 @@ endif # # regenerate sysinfo.gap if necessary # - -SYSINFO_GAP = $(abs_builddir)/gap -SYSINFO_GAC = $(abs_builddir)/gac - -#SYSINFO_CFLAGS is already initialized at this point -SYSINFO_CXXFLAGS = $(GAP_CXXFLAGS) -#SYSINFO_CPPFLAGS is already initialized at this point -SYSINFO_LDFLAGS = $(GAP_LDFLAGS) -SYSINFO_LIBS = $(GAP_LIBS) - define sysinfo_gap # This file has been generated by the GAP build system, # DO NOT EDIT MANUALLY! @@ -850,7 +884,7 @@ GAP="$(SYSINFO_GAP)" # GAC: path to the `gac` executable (may be a shell script) GAC="$(SYSINFO_GAC)" -# Build flags for use by `gac` resp. build systems: these correspond to +# Build flags for use by `gac` resp. package build systems: these correspond to # the usual variables as used by e.g. autotools, with the added prefix `GAP_`. GAP_CC="$(CC)" GAP_CXX="$(CXX)" @@ -859,6 +893,10 @@ GAP_CXXFLAGS="$(SYSINFO_CXXFLAGS)" GAP_CPPFLAGS="$(SYSINFO_CPPFLAGS)" GAP_LDFLAGS="$(SYSINFO_LDFLAGS)" GAP_LIBS="$(SYSINFO_LIBS)" + +# Extra flags for use by `gac` +GAC_CFLAGS="$(GAC_CFLAGS)" +GAC_LDFLAGS="$(GAC_LDFLAGS)" endef export sysinfo_gap @@ -1458,8 +1496,9 @@ doc/make_doc: $(srcdir)/doc/make_doc.in config.status CITATION: $(srcdir)/CITATION.in config.status @$(SHELL) ./config.status $@ -gac: $(srcdir)/cnf/gac.in config.status - @$(SHELL) ./config.status $@ +gac: $(srcdir)/cnf/gac.in + sed -e "s;@SYSINFO_GAPROOT@;$(abs_top_builddir);" < $< > $@ + chmod a+x $@ GNUmakefile: $(srcdir)/GNUmakefile.in config.status $(SHELL) ./config.status $@ diff --git a/cnf/gac.in b/cnf/gac.in index 92b78135c50..f3e11fd4fe2 100644 --- a/cnf/gac.in +++ b/cnf/gac.in @@ -49,34 +49,19 @@ ## -k|--gap-compiler ## -# absolute path of the directory in which GAP was compiled -abs_top_builddir="@abs_top_builddir@" - -# -libdir="@libdir@" - -# path to the GAP executable -gap_compiler="${abs_top_builddir}/gap" - -libtool="@SHELL@ ${abs_top_builddir}/libtool" - -# read sysinfo.gap, which should set GAP_CFLAGS, GAP_CPPFLAGS, etc. -. "${abs_top_builddir}/sysinfo.gap" - -# These three should be filled in by the standard autoconf procedures -c_compiler="$libtool --mode=compile $GAP_CC" -cxx_compiler="$libtool --mode=compile $GAP_CXX" - -# These will need special care -c_dyn_linker="$libtool --mode=link $GAP_CC -module -avoid-version -rpath $libdir" +# read sysinfo.gap, which sets GAP_CFLAGS, GAP_CPPFLAGS, etc. +. "@SYSINFO_GAPROOT@/sysinfo.gap" + +# Extract sysinfo settings... +gap_compiler="${GAP}" +c_compiler="${GAP_CC}" +cxx_compiler="${GAP_CXX}" +c_dyn_linker="${GAP_CC}" c_addlibs="" -SYS_IS_CYGWIN32=@SYS_IS_CYGWIN32@ -if [ X"$SYS_IS_CYGWIN32" = X"yes" ] ; then - c_dyn_linker="$c_dyn_linker -no-undefined -version-info 0:0:0" - # FIXME: use correct DLL path (also after "make install") - c_dyn_linker="$c_dyn_linker -Wl,${abs_top_builddir}/bin/${GAParch}/gap.dll" -fi +GAP_CFLAGS="${GAP_CFLAGS} ${GAC_CFLAGS}" +GAP_CXXFLAGS="${GAP_CXXFLAGS} ${GAC_CFLAGS}" +GAP_LDFLAGS="${GAP_LDFLAGS} ${GAC_LDFLAGS}" ############################################################################# @@ -118,18 +103,8 @@ cxx_compile () { ## c_link_dyn () { mkdir -p $(dirname $1) - echo ${c_dyn_linker} ${GAP_LDFLAGS} -o $1 $2 ${c_addlibs} - output_la=${1%.so}.la - output_dir=$(dirname $1) - ${c_dyn_linker} ${GAP_LDFLAGS} -o "$output_la" $2 ${c_addlibs} || exit 1 - if [ X"$SYS_IS_CYGWIN32" = X"yes" ] ; then - # GAP assumes shared libraries end in .so - for dllfile in $(cd $output_dir/.libs; ls *.dll); do - cp $output_dir/.libs/$dllfile $output_dir/${dllfile%.dll}.so - done - else - cp $output_dir/.libs/*.so $output_dir - fi; + echo ${c_dyn_linker} -o $1 $2 ${GAP_LDFLAGS} ${c_addlibs} + ${c_dyn_linker} -o $1 $2 ${GAP_LDFLAGS} ${c_addlibs} || exit 1 } @@ -164,12 +139,12 @@ process_c_file () { c_file=$2 if [ $comp_howfar != "object" ]; then - o_file=${gactmp}/$$_${name}.lo + o_file=${gactmp}/$$_${name}.o temps_o="${temps_o} ${o_file}" elif [ "X$output" != "X" ]; then o_file=$output else - o_file=${name}.lo + o_file=${name}.o fi c_compile $o_file $c_file if [ $comp_howfar = "link" ]; then @@ -189,12 +164,12 @@ process_cxx_file () { cxx_file=$2 if [ $comp_howfar != "object" ]; then - o_file=${gactmp}/$$_${name}.lo + o_file=${gactmp}/$$_${name}.o temps_o="${temps_o} ${o_file}" elif [ "X$output" != "X" ]; then o_file=$output else - o_file=${name}.lo + o_file=${name}.o fi cxx_compile $o_file $cxx_file if [ $comp_howfar = "link" ]; then @@ -360,7 +335,7 @@ for input in ${inputs}; do name=$(basename ${input} .o) process_o_file $name $input;; - *.lo) # look over '.lo' source files + *.lo) # look over '.lo' source files (for backwards compatibility) name=$(basename ${input} .lo) process_o_file $name $input;; esac @@ -374,7 +349,7 @@ if [ $comp_howfar = "link" ]; then exit 1 fi - if [ "X${output}" = "X" ]; then output="${name}.la"; fi + if [ "X${output}" = "X" ]; then output="${name}.so"; fi c_link_dyn ${output} "${objects}" if [ "$savetemps" = "true" ]; then diff --git a/configure.ac b/configure.ac index 6ee74e7cfa6..114d6685532 100644 --- a/configure.ac +++ b/configure.ac @@ -1025,5 +1025,4 @@ AC_CONFIG_FILES([GNUmakefile]) AC_CONFIG_FILES([CITATION]) AC_CONFIG_FILES([doc/make_doc], [chmod +x doc/make_doc]) AC_CONFIG_FILES([doc/versiondata]) -AC_CONFIG_FILES([gac:cnf/gac.in], [chmod +x gac]) AC_OUTPUT diff --git a/etc/Makefile.gappkg b/etc/Makefile.gappkg index 8a8b2ad3a7b..4b0ea9574fe 100644 --- a/etc/Makefile.gappkg +++ b/etc/Makefile.gappkg @@ -40,12 +40,6 @@ # read GAP's build settings include $(GAPPATH)/sysinfo.gap -# hack to support GAP <= 4.9 -ifndef GAP_KERNEL_MAJOR_VERSION - KEXT_CFLAGS += -I$(GAP_LIB_DIR)/src - KEXT_CXXFLAGS += -I$(GAP_LIB_DIR)/src -endif - # honor used supplied flags KEXT_CFLAGS += $(CPPFLAGS) KEXT_CFLAGS += $(CFLAGS) @@ -74,12 +68,12 @@ all: $(KEXT_SO) ######################################################################## # Object files -# For each file FOO.c in SOURCES, add gen/FOO.lo to KEXT_OBJS; similar +# For each file FOO.c in SOURCES, add gen/FOO.o to KEXT_OBJS; similar # for .cc files ######################################################################## -KEXT_OBJS = $(patsubst %.s,gen/%.lo, \ - $(patsubst %.cc,gen/%.lo, \ - $(patsubst %.c,gen/%.lo, \ +KEXT_OBJS = $(patsubst %.s,gen/%.o, \ + $(patsubst %.cc,gen/%.o, \ + $(patsubst %.c,gen/%.o, \ $(KEXT_SOURCES)))) ######################################################################## @@ -100,7 +94,7 @@ endif ######################################################################## # List of all (potential) dependency files, derived from KEXT_OBJS -KEXT_DEPFILES = $(patsubst %.lo,%.d,$(KEXT_OBJS)) +KEXT_DEPFILES = $(patsubst %.o,%.d,$(KEXT_OBJS)) # Include the dependency tracking files -include $(KEXT_DEPFILES) @@ -117,19 +111,19 @@ KEXT_DEPFLAGS = -MQ "$@" -MMD -MP -MF $(@D)/$(*F).d # build rule for C code # The dependency on Makefile ensures that re-running configure recompiles everything -gen/%.lo: %.c Makefile +gen/%.o: %.c Makefile @mkdir -p $(@D) $(QUIET_GAC)$(GAC) -d -p "$(KEXT_DEPFLAGS)" -p "$(KEXT_CFLAGS)" -c $< -o $@ # build rule for C++ code # The dependency on Makefile ensures that re-running configure recompiles everything -gen/%.lo: %.cc Makefile +gen/%.o: %.cc Makefile @mkdir -p $(@D) $(QUIET_GAC)$(GAC) -d -p "$(KEXT_DEPFLAGS)" -p "$(KEXT_CXXFLAGS)" -c $< -o $@ # build rule for assembler code # The dependency on Makefile ensures that re-running configure recompiles everything -gen/%.lo: %.s Makefile +gen/%.o: %.s Makefile @mkdir -p $(@D) $(QUIET_GAC)$(GAC) -d -p "$(KEXT_DEPFLAGS)" -p "$(KEXT_CFLAGS)" -c $< -o $@