From 020ea408b4e0323e280a38ff19517f812a5fd393 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Tue, 30 May 2023 14:58:04 -0400 Subject: [PATCH] Makefile: enable symbol versioning by default This enables symbol versioning by default, with the version string `JL_LIBJULIA_1.10` (the version suffix is the SOMAJOR in general). As part of this change, the SOMAJOR has also been changed to be MAJOR.MINOR instead of just MAJOR. This is required to allow multiple minor releases of libjulia to live side-by-side in the same process. `SYMBOL_VERSION_SUFFIX` is provided to allow appending an additional unique "salt" to SOMAJOR, which can be helpful for creating template binaries that will be "version-stamped" after distribution. --- Make.inc | 18 +++++++----------- cli/Makefile | 2 +- src/Makefile | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Make.inc b/Make.inc index 7cf16b0f04155..d78c99f5de63c 100644 --- a/Make.inc +++ b/Make.inc @@ -188,21 +188,17 @@ JULIA_MINOR_VERSION := $(shell echo $(JULIA_VERSION) | cut -d'-' -f 1 | cut -d'. JULIA_PATCH_VERSION := $(shell echo $(JULIA_VERSION) | cut -d'-' -f 1 | cut -d'+' -f 1 | cut -d'.' -f 3) # libjulia's SONAME will follow the format libjulia.so.$(SOMAJOR). Before v1.0.0, -# SOMAJOR will be a two-decimal value, e.g. libjulia.so.0.5, whereas at and beyond -# v1.0.0, SOMAJOR will be simply the major version number, e.g. libjulia.so.1 +# somajor was a two-decimal value (e.g. libjulia.so.0.5). During v1.0.x - v1.9.x, +# somajor was simply the major version number (e.g. libjulia.so.1). Starting in +# v1.10.0, somajor is major.minor again (e.g. libjulia.so.1.10) # The file itself will ultimately symlink to libjulia.so.$(SOMAJOR).$(SOMINOR) -ifeq ($(JULIA_MAJOR_VERSION),0) SOMAJOR := $(JULIA_MAJOR_VERSION).$(JULIA_MINOR_VERSION) SOMINOR := $(JULIA_PATCH_VERSION) -else -SOMAJOR := $(JULIA_MAJOR_VERSION) -SOMINOR := $(JULIA_MINOR_VERSION) -endif -# In order to load multiple libjulia's with different DEFAULT_SYMBOL_VERSION -# each must have a unique SONAME -ifdef DEFAULT_SYMBOL_VERSION -SOMAJOR := "$(SOMAJOR)-$(DEFAULT_SYMBOL_VERSION)" +# This suffix affects libjulia's SONAME and the symbol version associated with +# all of its exported symbols. +ifdef SYMBOL_VERSION_SUFFIX +SOMAJOR := $(SOMAJOR)_$(SYMBOL_VERSION_SUFFIX) endif ifneq ($(NO_GIT), 1) diff --git a/cli/Makefile b/cli/Makefile index e24a14cc69d59..b6a2b48ebf044 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -149,7 +149,7 @@ $(build_bindir)/julia-debug$(EXE): $(EXE_DOBJS) $(build_shlibdir)/libjulia-debug @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(DEBUGFLAGS) $(EXE_DOBJS) -o $@ $(LOADER_LDFLAGS) $(RPATH) -ljulia-debug) $(BUILDDIR)/julia.expmap: $(SRCDIR)/julia.expmap.in - sed <'$<' >'$@' -e 's/@JULIA_SHLIB_SYMBOL_VERSION@/$(DEFAULT_SYMBOL_VERSION)/' + sed <'$<' >'$@' -e 's/@JULIA_SHLIB_SYMBOL_VERSION@/JL_LIBJULIA_$(SOMAJOR)/' clean: | $(CLEAN_TARGETS) rm -f $(BUILDDIR)/*.o $(BUILDDIR)/*.dbg.obj diff --git a/src/Makefile b/src/Makefile index 79a6a7838cc50..8d8cf5f9ceaeb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -364,7 +364,7 @@ $(BUILDDIR)/julia_version.h: $(JULIAHOME)/VERSION CXXLD = $(CXX) -shared $(BUILDDIR)/julia.expmap: $(SRCDIR)/julia.expmap.in - sed <'$<' >'$@' -e 's/@JULIA_SHLIB_SYMBOL_VERSION@/$(DEFAULT_SYMBOL_VERSION)/' + sed <'$<' >'$@' -e 's/@JULIA_SHLIB_SYMBOL_VERSION@/JL_LIBJULIA_$(SOMAJOR)/' $(build_shlibdir)/libjulia-internal.$(JL_MAJOR_MINOR_SHLIB_EXT): $(BUILDDIR)/julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(LIBUV) @$(call PRINT_LINK, $(CXXLD) $(call IMPLIB_FLAGS,$@) $(JCXXFLAGS) $(JL_CXXFLAGS) $(CXXLDFLAGS) $(SHIPFLAGS) $(OBJS) $(RPATH_LIB) -o $@ \