From 8ba9b548a4e2c5a2b3523b9d83cefa0d876fdd37 Mon Sep 17 00:00:00 2001 From: "Peter S. Housel" Date: Wed, 26 Jan 2022 20:49:22 -0800 Subject: [PATCH 1/3] jamfiles: Support linking Dylan libraries statically on POSIX This change makes it possible to combine Dylan libraries and all of their dependencies into a single unified executable using the -UNIFY build option. The unified executable will be stored in the sbin (static executables binary) directory of the personal-root target. * sources/jamfiles/posix-build.jam (SBINDIR): New global representing the destination directory for static executables. (UNIFYLINK): New global representing the command used to link the unified executable. (rule DylanLibrary): Create a unified executable target and a unified static library archive for each library. Rename the global _lib_$(_i) to _lflag_$(_i). (rule DylanLibraryFiles): Add library objects to the unified static library archives. (rule DylanLibraryLinkerOptions): Add linker options to the unified executable target, and store them so they can be added to some final executable that depends on the current library. (rule DylanLibraryCObjects): Add C objects to the unified static library archives. (rule DylanLibraryCSources): Add C compiled objects to the unified static library archives. (rule DylanLibraryUses): Collect library dependencies and linker options of used libraries and add them to the unified executable. (rule DylanLibraryClosure): Rename the global _lib_$(_i) to _lflag_$(_i). (rule UnifyArchive, actions UnifyArchive): Create static library archives. (rule UnifyEXE, actions UnifyEXE): Create static executbles. (rule FLIBName): Rule for naming static archives. (rule FULIBName): Rule for naming static archives built to contain all executables of a library. * sources/jamfiles/*-linux-build.jam (rtclibs): Add -ldl since the spy interface code in the dylan library references dlopen(). * sources/jamfiles/shared-darwin-build.jam (actions UnifyEXE): Add an override for macOS support. --- sources/jamfiles/aarch64-linux-build.jam | 2 +- sources/jamfiles/arm-linux-build.jam | 2 +- sources/jamfiles/posix-build.jam | 86 +++++++++++++++++++++--- sources/jamfiles/riscv64-linux-build.jam | 2 +- sources/jamfiles/shared-darwin-build.jam | 6 ++ sources/jamfiles/x86_64-linux-build.jam | 2 +- 6 files changed, 85 insertions(+), 15 deletions(-) diff --git a/sources/jamfiles/aarch64-linux-build.jam b/sources/jamfiles/aarch64-linux-build.jam index 58f50070e7..50c5eea385 100644 --- a/sources/jamfiles/aarch64-linux-build.jam +++ b/sources/jamfiles/aarch64-linux-build.jam @@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ; # # Overrides/redefinitions # -rtclibs += -lpthread -lrt ; +rtclibs += -lpthread -ldl -lrt ; diff --git a/sources/jamfiles/arm-linux-build.jam b/sources/jamfiles/arm-linux-build.jam index e0f615a50e..7d07ffec8a 100644 --- a/sources/jamfiles/arm-linux-build.jam +++ b/sources/jamfiles/arm-linux-build.jam @@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ; # # Overrides/redefinitions # -rtclibs += -lpthread -lrt ; +rtclibs += -lpthread -ldl -lrt ; diff --git a/sources/jamfiles/posix-build.jam b/sources/jamfiles/posix-build.jam index 6c5bf5a716..40edb559fa 100644 --- a/sources/jamfiles/posix-build.jam +++ b/sources/jamfiles/posix-build.jam @@ -4,6 +4,7 @@ { local _lib = lib ; local _bin = bin ; + local _sbin = sbin ; local _inc = include ; # SYSTEM_ROOT is set by the build-system @@ -18,6 +19,7 @@ # . is set by the build system LIBDIR ?= $(_lib:P=$(PERSONAL_ROOT:E=$(.:P))) ; BINDIR ?= $(_bin:P=$(PERSONAL_ROOT:E=$(.:P))) ; + SBINDIR ?= $(_sbin:P=$(PERSONAL_ROOT:E=$(.:P))) ; HDRS ?= $(SYSTEM_INCDIR) ; } @@ -53,6 +55,7 @@ STRIP ?= strip ; CCFLAGS += -fPIC ; LINK ?= $(CC) ; +UNIFYLINK ?= $(CC) -Bstatic ; LINKFLAGS ?= $(CCFLAGS) ; # @@ -122,26 +125,30 @@ rule DylanLibrary image : version { # Link a Dylan library as a shared library or executable image. local _dll = [ FDLLName $(image) ] ; - local _lib = [ FLIBName $(image) ] ; + local _ulib = [ FULIBName $(image) ] ; + local _lflag = [ FLIBFlag $(image) ] ; local _exe = [ FEXEName $(image) ] ; + local _uexe = $(_exe:G=unify) ; # Here we save the name and search directory of the DLL for this library. _dll_$(image[1]:L) = $(_dll) ; - _lib_$(image[1]:L) = $(_lib) ; + _ulib_$(image[1]:L) = $(_ulib) ; + _lflag_$(image[1]:L) = $(_lflag) ; if ! $(SYSTEM) && ! $(PERSONAL_ROOT) { _dir_$(image[1]:L) = $(LIBDIR) ; } # Shared libraries and executable images - MakeLocate $(_dll) : $(LIBDIR) ; + MakeLocate $(_dll) $(_ulib) : $(LIBDIR) ; MakeLocate $(_exe) : $(BINDIR) ; + MakeLocate $(_uexe) : $(SBINDIR) ; # Initial library search path LIBPATH on $(_dll) = $(PERSONAL_LIBDIR) ; - LIBPATH on $(_exe) = $(PERSONAL_LIBDIR:E=$(LIBDIR)) ; + LIBPATH on $(_exe) $(_uexe) = $(PERSONAL_LIBDIR:E=$(LIBDIR)) ; # Install needed runtime libraries locally if $(image[1]:L) = dylan { @@ -182,10 +189,16 @@ rule DylanLibrary image : version { SEARCH on $(_obj) $(_asm) = $(SEARCH_SOURCE) ; Depends $(_exe) : $(_dll) ; - LINKLIBS on $(_exe) += $(_lib) ; - LINKFLAGS on $(_exe) = $(LINKFLAGS) $(LINKFLAGSEXE) ; + LINKLIBS on $(_exe) += $(_lflag) ; + LINKFLAGS on $(_exe) $(_uexe) = $(LINKFLAGS) $(LINKFLAGSEXE) ; LinkEXE $(_exe) : $(_obj) ; + # Dylan glue must appear first in the statically-linked executable + # so that the system initializations are performed in the right + # order + local _glue = _glue$(SUFOUT) ; + UnifyEXE $(_uexe) : $(_glue:G=dylan) $(_obj) $(_ulib) ; + if $(COMPILER_BACK_END) = c { LINKFLAGS on $(_exe) += [ on $(_exe) FIncludes $(HDRS) ] ; } @@ -196,10 +209,11 @@ rule DylanLibrary image : version { if ! $(PARENT) { Depends dll : $(_dll) ; Depends exe : $(_exe) ; + Depends unify-exe : $(_uexe) ; - Clean clean : $(_dll) $(_exe) $(_mkf) $(_obj) $(_asm) ; + Clean clean : $(_dll) $(_exe) $(_uexe) $(_mkf) $(_obj) $(_asm) ; } - Clean clean-all : $(_dll) $(_exe) $(_mkf) $(_obj) $(_asm) ; + Clean clean-all : $(_dll) $(_exe) $(_uexe) $(_mkf) $(_obj) $(_asm) ; # Mark the library version @@ -214,6 +228,7 @@ rule DylanLibraryFiles image : files { # Link Dylan-derived object files into the resulting shared library. if ! $(SYSTEM) { local _dll = [ FDLLName $(image) ] ; + local _ulib = [ FULIBName $(image) ] ; local _out = [ FGristFiles _glue$(SUFOUT) $(files:S=$(SUFOUT)) ] ; local _asm = [ FGristFiles _glue$(SUFASM) $(files:S=$(SUFASM)) ] ; @@ -234,6 +249,7 @@ rule DylanLibraryFiles image : files { Cc $(_mobj) : $(_i) ; } LinkDLL $(_dll) : $(_mobj) ; + UnifyArchive $(_ulib) : $(_mobj) ; } } else { LinkDLL $(_dll) : $(_out) ; @@ -254,9 +270,10 @@ rule DylanLibraryLinkerOptions image : options { local _dll = [ FDLLName $(image) ] ; local _exe = [ FEXEName $(image) ] ; + local _uexe = $(_exe:G=unify) ; - LINKLIBS on $(_dll) += $(options) ; - LINKLIBS on $(_exe) += $(options) ; + LINKLIBS on $(_dll) $(_exe) $(_uexe) += $(options) ; + _uopt_$(image[1]:L) += $(options) ; } rule DylanLibraryBaseAddress image : address { @@ -305,8 +322,10 @@ rule DylanLibraryCObjects image : objects { # Link C (or other externally-derived) object files into the shared library. if ! $(SYSTEM) { local _dll = [ FDLLName $(image) ] ; + local _ulib = [ FULIBName $(image) ] ; SEARCH on $(objects) = $(SEARCH_SOURCE) ; LinkDLL $(_dll) : $(objects) ; + UnifyArchive $(_ulib) : $(objects) ; } } @@ -317,6 +336,7 @@ rule DylanLibraryCSources image : sources { # Link C source files into the shared library. if ! $(SYSTEM) { local _dll = [ FDLLName $(image) ] ; + local _ulib = [ FULIBName $(image) ] ; local _exe = [ FEXEName $(image) ] ; local _i ; @@ -328,6 +348,7 @@ rule DylanLibraryCSources image : sources { Cc $(_obj) : $(_i) ; LinkDLL $(_dll) : $(_obj) ; + UnifyArchive $(_ulib) : $(_obj) ; } } } @@ -426,9 +447,18 @@ rule DylanLibraryUses image : library : dir { } DylanLibraryClosure $(image) : $(library:L) ; + + local _exe = [ FEXEName $(image) ] ; + local _uexe = $(_exe:G=unify) ; + for _i in $(_use_$(image[1]:L)) { + Depends $(_uexe) : $(_ulib_$(_i)) ; + NEEDLIBS on $(_uexe) += $(_ulib_$(_i)) ; + LINKLIBS on $(_uexe) += $(_clib_$(_i)) $(_uopt_$(_i)) ; + } } rule DylanLibraryClosure image : libraries { + #Echo DylanLibraryClosure $(image) ":" $(libraries) ; local _dll = [ FDLLName $(image) ] ; local _exe = [ FEXEName $(image) ] ; @@ -436,8 +466,9 @@ rule DylanLibraryClosure image : libraries { for _i in $(libraries) { if ! $(_i) in $(_use_$(image[1]:L)) { _use_$(image[1]:L) += $(_i) ; + Depends $(_dll) $(_exe) : $(_dll_$(_i)) ; - LINKLIBS on $(_dll) $(_exe) += $(_lib_$(_i)) $(_clib_$(_i)) ; + LINKLIBS on $(_dll) $(_exe) += $(_lflag_$(_i)) $(_clib_$(_i)) ; LIBPATH on $(_dll) $(_exe) += $(_dir_$(_i)) ; DylanLibraryClosure $(image) : $(_use_$(_i)) ; @@ -460,6 +491,15 @@ actions together LinkDLL bind NEEDLIBS { $(STRIP) -s $(<:Q) } +rule UnifyArchive { + #Echo UnifyArchive $(<) ":" $(>) ; + Depends $(<) : $(>) ; +} + +actions together UnifyArchive { + $(AR) $(<:Q) $(>:Q) +} + rule LinkEXE { #Echo LinkEXE $(<) ":" $(>) ; Depends $(<) : $(>) ; @@ -472,6 +512,18 @@ actions LinkEXE bind NEEDLIBS { $(STRIP) -s $(<:Q) } +rule UnifyEXE { + #Echo UnifyEXE $(<) ":" $(>) ; + Depends $(<) : $(>) ; +} + +actions UnifyEXE bind NEEDLIBS { + $(UNIFYLINK) -o $(<:Q) $(LINKFLAGS) $(>:Q) -L"$(LIBPATH)" -Wl,--start-group $(NEEDLIBS:Q) $(LINKLIBS) -Wl,--end-group + $(OBJCOPY) $(<:Q) $(<:Q).dbg + $(OBJCOPY) --add-gnu-debuglink=$(<:Q).dbg $(<:Q) + $(STRIP) -s $(<:Q) +} + # # Utility rules # @@ -485,6 +537,18 @@ rule FDLLName { } rule FLIBName { + if $(<[2]) { + return lib$(<[2]:LS=$(SUFLIB)) ; + } else { + return lib$(<[1]:LS=$(SUFLIB)) ; + } +} + +rule FULIBName { + return [ FLIBName $(<),unify ] ; +} + +rule FLIBFlag { if $(<[2]) { return -l$(<[2]:L) ; } else { diff --git a/sources/jamfiles/riscv64-linux-build.jam b/sources/jamfiles/riscv64-linux-build.jam index c50f53c30d..4c70f28350 100644 --- a/sources/jamfiles/riscv64-linux-build.jam +++ b/sources/jamfiles/riscv64-linux-build.jam @@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ; # # Overrides/redefinitions # -rtclibs += -lpthread -lrt ; +rtclibs += -lpthread -ldl -lrt ; diff --git a/sources/jamfiles/shared-darwin-build.jam b/sources/jamfiles/shared-darwin-build.jam index 96955fbb60..bbfc7883a9 100644 --- a/sources/jamfiles/shared-darwin-build.jam +++ b/sources/jamfiles/shared-darwin-build.jam @@ -34,3 +34,9 @@ actions LinkEXE bind NEEDLIBS { $(DSYMUTIL) $(<:Q) && $(STRIP) -S $(<:Q) } + +actions UnifyEXE bind NEEDLIBS { + $(UNIFYLINK) -o $(<:Q) $(LINKFLAGS) $(>:Q) -L"$(LIBPATH)" $(NEEDLIBS:Q) $(LINKLIBS) && + $(DSYMUTIL) $(<:Q) && + $(STRIP) -S $(<:Q) +} diff --git a/sources/jamfiles/x86_64-linux-build.jam b/sources/jamfiles/x86_64-linux-build.jam index 77e8d06ec9..ea88e95ab1 100644 --- a/sources/jamfiles/x86_64-linux-build.jam +++ b/sources/jamfiles/x86_64-linux-build.jam @@ -24,4 +24,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ; # # Overrides/redefinitions # -rtclibs += -lpthread -lrt ; +rtclibs += -lpthread -ldl -lrt ; From 9a2948da77ed5315821227a5774194acdbefc610 Mon Sep 17 00:00:00 2001 From: "Peter S. Housel" Date: Wed, 26 Jan 2022 22:07:28 -0800 Subject: [PATCH 2/3] Update release version to 2022.1pre * configure.ac: Update AC_INIT to 2022.1pre * sources/lib/release-info/common-info.dylan ($release-version): Update to 2022.1pre. * documentation/release-notes/source/2021.1.rst: Rename from 2022.1.rst. --- configure.ac | 2 +- .../release-notes/source/{2021.1.rst => 2022.1.rst} | 6 +++--- sources/lib/release-info/common-info.dylan | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename documentation/release-notes/source/{2021.1.rst => 2022.1.rst} (96%) diff --git a/configure.ac b/configure.ac index 1ec2a33c10..d8ecb6073e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Open Dylan], [2021.1pre]) +AC_INIT([Open Dylan], [2022.1pre]) AC_PREREQ(2.50) # Directory for config.guess etc. diff --git a/documentation/release-notes/source/2021.1.rst b/documentation/release-notes/source/2022.1.rst similarity index 96% rename from documentation/release-notes/source/2021.1.rst rename to documentation/release-notes/source/2022.1.rst index 2292bc3c6b..df1ab32e01 100644 --- a/documentation/release-notes/source/2021.1.rst +++ b/documentation/release-notes/source/2022.1.rst @@ -1,11 +1,11 @@ ***************** -Open Dylan 2021.1 +Open Dylan 2022.1 ***************** -This document describes the 2021.1 release of Open Dylan, released XX MMM, 2021. +This document describes the 2022.1 release of Open Dylan, released XX MMM, 2022. This release contains many enhancements and bug fixes, highlights of which are listed below. For complete details see `the opendylan commit logs -`_. (Note +`_. (Note that some commit logs, for example for testworks and other libraries that are included in Open Dylan as git submodules, may be in other repositories.) diff --git a/sources/lib/release-info/common-info.dylan b/sources/lib/release-info/common-info.dylan index f2490cc827..5b1c0033da 100644 --- a/sources/lib/release-info/common-info.dylan +++ b/sources/lib/release-info/common-info.dylan @@ -22,7 +22,7 @@ define constant $help-filename = "opendylan.chm"; /// Release constants define constant $release-product-name = "Open Dylan"; define constant $release-product-identifier = "opendylan"; -define constant $release-version = "2021.1pre"; +define constant $release-version = "2022.1pre"; define constant $release-copyright = "Copyright (c) 1997-2004, Functional Objects, Inc.\n" From c2966d04433390b0e2e5aece671132ff8487b97a Mon Sep 17 00:00:00 2001 From: "Peter S. Housel" Date: Wed, 26 Jan 2022 22:23:55 -0800 Subject: [PATCH 3/3] release-notes: Note addition of static executables support --- documentation/release-notes/source/2022.1.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/documentation/release-notes/source/2022.1.rst b/documentation/release-notes/source/2022.1.rst index df1ab32e01..303ce76682 100644 --- a/documentation/release-notes/source/2022.1.rst +++ b/documentation/release-notes/source/2022.1.rst @@ -26,6 +26,12 @@ Compiler * Improved source line tracking in the generated code, reducing the occurence of code marked as being at line 0 by the debugger. +* Added support for linking executable Dylan libraries and all of + their dependencies into a single unified executable using the + ``-unify`` build option. The unified executable will be stored in + the :file:`sbin` (static executables binary) directory of the + personal-root. + Run-time ========