Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support linking unified (static) executables on POSIX platforms #1416

Merged
merged 3 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
<https://github.com/dylan-lang/opendylan/compare/v2020.1.0...v2021.1.0>`_. (Note
<https://github.com/dylan-lang/opendylan/compare/v2020.1.0...v2022.1.0>`_. (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.)

Expand All @@ -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
========

Expand Down
2 changes: 1 addition & 1 deletion sources/jamfiles/aarch64-linux-build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
#
# Overrides/redefinitions
#
rtclibs += -lpthread -lrt ;
rtclibs += -lpthread -ldl -lrt ;
2 changes: 1 addition & 1 deletion sources/jamfiles/arm-linux-build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
#
# Overrides/redefinitions
#
rtclibs += -lpthread -lrt ;
rtclibs += -lpthread -ldl -lrt ;
86 changes: 75 additions & 11 deletions sources/jamfiles/posix-build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
local _lib = lib ;
local _bin = bin ;
local _sbin = sbin ;
local _inc = include ;

# SYSTEM_ROOT is set by the build-system
Expand All @@ -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) ;
}

Expand Down Expand Up @@ -53,6 +55,7 @@ STRIP ?= strip ;
CCFLAGS += -fPIC ;

LINK ?= $(CC) ;
UNIFYLINK ?= $(CC) -Bstatic ;
LINKFLAGS ?= $(CCFLAGS) ;

#
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) ] ;
}
Expand All @@ -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

Expand All @@ -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)) ] ;
Expand All @@ -234,6 +249,7 @@ rule DylanLibraryFiles image : files {
Cc $(_mobj) : $(_i) ;
}
LinkDLL $(_dll) : $(_mobj) ;
UnifyArchive $(_ulib) : $(_mobj) ;
}
} else {
LinkDLL $(_dll) : $(_out) ;
Expand All @@ -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 {
Expand Down Expand Up @@ -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) ;
}
}

Expand All @@ -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 ;
Expand All @@ -328,6 +348,7 @@ rule DylanLibraryCSources image : sources {
Cc $(_obj) : $(_i) ;

LinkDLL $(_dll) : $(_obj) ;
UnifyArchive $(_ulib) : $(_obj) ;
}
}
}
Expand Down Expand Up @@ -426,18 +447,28 @@ 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) ] ;

local _i ;
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)) ;
Expand All @@ -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 $(<) : $(>) ;
Expand All @@ -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
#
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sources/jamfiles/riscv64-linux-build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
#
# Overrides/redefinitions
#
rtclibs += -lpthread -lrt ;
rtclibs += -lpthread -ldl -lrt ;
6 changes: 6 additions & 0 deletions sources/jamfiles/shared-darwin-build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion sources/jamfiles/x86_64-linux-build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
#
# Overrides/redefinitions
#
rtclibs += -lpthread -lrt ;
rtclibs += -lpthread -ldl -lrt ;
2 changes: 1 addition & 1 deletion sources/lib/release-info/common-info.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down