From 3dca759f3fc0f44ce3aea63672cf2d64321b2595 Mon Sep 17 00:00:00 2001 From: Mukilan Thiyagarajan Date: Wed, 9 Jul 2014 00:47:00 +0200 Subject: [PATCH] Bug 1000994 - Allow specifying SONAME of a shared library in moz.build. r=glandium --- config/config.mk | 2 ++ config/rules.mk | 6 ++++++ configure.in | 16 ++++++++-------- js/src/configure.in | 16 ++++++++-------- python/mozbuild/mozbuild/frontend/emitter.py | 7 +++++++ .../mozbuild/frontend/sandbox_symbols.py | 8 ++++++++ 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/config/config.mk b/config/config.mk index ca83dabf738e..f9f55ebb1948 100644 --- a/config/config.mk +++ b/config/config.mk @@ -64,6 +64,7 @@ _MOZBUILD_EXTERNAL_VARIABLES := \ RESOURCE_FILES \ SDK_HEADERS \ SIMPLE_PROGRAMS \ + SONAME \ TEST_DIRS \ TIERS \ TOOL_DIRS \ @@ -148,6 +149,7 @@ CHECK_VARS := \ XPI_PKGNAME \ INSTALL_EXTENSION_ID \ SHARED_LIBRARY_NAME \ + SONAME \ STATIC_LIBRARY_NAME \ $(NULL) diff --git a/config/rules.mk b/config/rules.mk index f88e67fcfbec..19271dce7f4b 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -177,6 +177,12 @@ else SHARED_LIBRARY := $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX) endif +ifdef SONAME +DSO_SONAME = $(DLL_PREFIX)$(SONAME)$(DLL_SUFFIX) +else +DSO_SONAME = $(notdir $@) +endif + EMBED_MANIFEST_AT=2 endif # MKSHLIB diff --git a/configure.in b/configure.in index 4fa32bf4d7d2..894c1b15987c 100644 --- a/configure.in +++ b/configure.in @@ -1312,8 +1312,8 @@ if test "$GNU_CC"; then fi # FIXME: Let us build with strict aliasing. bug 414641. CFLAGS="$CFLAGS -fno-strict-aliasing" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' WARNINGS_AS_ERRORS='-Werror' DSO_CFLAGS='' DSO_PIC_CFLAGS='-fPIC' @@ -1461,8 +1461,8 @@ elif test "$SOLARIS_SUNPRO_CC"; then fi _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT' else - MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' - MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' + MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' DSO_LDOPTS='-shared' if test "$GNU_LD"; then @@ -2279,8 +2279,8 @@ ia64*-hpux*) if test "$LIBRUNPATH"; then DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS" fi - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@' ;; *-openbsd*) @@ -2323,8 +2323,8 @@ ia64*-hpux*) [LDFLAGS=$_SAVE_LDFLAGS]) fi MOZ_OPTIMIZE_FLAGS="-xO4" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' MKSHLIB_FORCE_ALL='-z allextract' MKSHLIB_UNFORCE_ALL='-z defaultextract' DSO_LDOPTS='-G' diff --git a/js/src/configure.in b/js/src/configure.in index 4a0669005160..bfe205958ddc 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -1099,8 +1099,8 @@ if test "$GNU_CC"; then if test "${OS_ARCH}" != Darwin; then CFLAGS="$CFLAGS -fgnu89-inline" fi - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' DSO_LDOPTS='-shared' if test "$GCC_USE_GNU_LD"; then # Some tools like ASan use a runtime library that is only @@ -1192,8 +1192,8 @@ elif test "$SOLARIS_SUNPRO_CC"; then fi _DEFINES_CFLAGS='$(ACDEFINES) -D_JS_CONFDEFS_H_ -DMOZILLA_CLIENT' else - MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' - MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' + MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' DSO_LDOPTS='-shared' if test "$GNU_LD"; then @@ -1799,8 +1799,8 @@ ia64*-hpux*) if test "$LIBRUNPATH"; then DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS" fi - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@' ;; *-openbsd*) @@ -1840,8 +1840,8 @@ ia64*-hpux*) [LDFLAGS=$_SAVE_LDFLAGS]) fi MOZ_OPTIMIZE_FLAGS="-xO4" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@' MKSHLIB_FORCE_ALL='-z allextract' MKSHLIB_UNFORCE_ALL='-z defaultextract' DSO_LDOPTS='-G' diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 3d3363c56063..25bdadb6bcfb 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -389,6 +389,13 @@ class TreeMetadataEmitter(LoggingMixin): self._final_libs.append((sandbox['OBJDIR'], libname, final_lib)) passthru.variables['FORCE_STATIC_LIB'] = True + soname = sandbox.get('SONAME') + if soname: + if not sandbox.get('FORCE_SHARED_LIB'): + raise SandboxValidationError('SONAME applicable only for shared libraries') + else: + passthru.variables['SONAME'] = soname + # While there are multiple test manifests, the behavior is very similar # across them. We enforce this by having common handling of all # manifests and outputting a single class type with the differences diff --git a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py index 6115c4c31651..c47f8c0e7842 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py +++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py @@ -417,6 +417,14 @@ VARIABLES = { ``BIN_SUFFIX``, the name will remain unchanged. """, 'binaries'), + 'SONAME': (unicode, unicode, + """The soname of the shared object currently being linked + + soname is the "logical name" of a shared object, often used to provide + version backwards compatibility. This variable makes sense only for + shared objects, and is supported only on some unix platforms. + """, 'binaries'), + 'HOST_SIMPLE_PROGRAMS': (StrictOrderingOnAppendList, list, """Compile a list of host executable names.