Skip to content

Commit 6ca4e26

Browse files
authored
Merge pull request #1416 from housel/unify-the-world
Support linking unified (static) executables on POSIX platforms
2 parents 39a383c + c2966d0 commit 6ca4e26

9 files changed

+96
-20
lines changed

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([Open Dylan], [2021.1pre])
1+
AC_INIT([Open Dylan], [2022.1pre])
22
AC_PREREQ(2.50)
33

44
# Directory for config.guess etc.

documentation/release-notes/source/2021.1.rst documentation/release-notes/source/2022.1.rst

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
*****************
2-
Open Dylan 2021.1
2+
Open Dylan 2022.1
33
*****************
44

5-
This document describes the 2021.1 release of Open Dylan, released XX MMM, 2021.
5+
This document describes the 2022.1 release of Open Dylan, released XX MMM, 2022.
66
This release contains many enhancements and bug fixes, highlights
77
of which are listed below. For complete details see `the opendylan commit logs
8-
<https://github.com/dylan-lang/opendylan/compare/v2020.1.0...v2021.1.0>`_. (Note
8+
<https://github.com/dylan-lang/opendylan/compare/v2020.1.0...v2022.1.0>`_. (Note
99
that some commit logs, for example for testworks and other libraries that are
1010
included in Open Dylan as git submodules, may be in other repositories.)
1111

@@ -26,6 +26,12 @@ Compiler
2626
* Improved source line tracking in the generated code, reducing the
2727
occurence of code marked as being at line 0 by the debugger.
2828

29+
* Added support for linking executable Dylan libraries and all of
30+
their dependencies into a single unified executable using the
31+
``-unify`` build option. The unified executable will be stored in
32+
the :file:`sbin` (static executables binary) directory of the
33+
personal-root.
34+
2935
Run-time
3036
========
3137

sources/jamfiles/aarch64-linux-build.jam

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
2323
#
2424
# Overrides/redefinitions
2525
#
26-
rtclibs += -lpthread -lrt ;
26+
rtclibs += -lpthread -ldl -lrt ;

sources/jamfiles/arm-linux-build.jam

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
2323
#
2424
# Overrides/redefinitions
2525
#
26-
rtclibs += -lpthread -lrt ;
26+
rtclibs += -lpthread -ldl -lrt ;

sources/jamfiles/posix-build.jam

+75-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{
55
local _lib = lib ;
66
local _bin = bin ;
7+
local _sbin = sbin ;
78
local _inc = include ;
89

910
# SYSTEM_ROOT is set by the build-system
@@ -18,6 +19,7 @@
1819
# . is set by the build system
1920
LIBDIR ?= $(_lib:P=$(PERSONAL_ROOT:E=$(.:P))) ;
2021
BINDIR ?= $(_bin:P=$(PERSONAL_ROOT:E=$(.:P))) ;
22+
SBINDIR ?= $(_sbin:P=$(PERSONAL_ROOT:E=$(.:P))) ;
2123
HDRS ?= $(SYSTEM_INCDIR) ;
2224
}
2325

@@ -53,6 +55,7 @@ STRIP ?= strip ;
5355
CCFLAGS += -fPIC ;
5456

5557
LINK ?= $(CC) ;
58+
UNIFYLINK ?= $(CC) -Bstatic ;
5659
LINKFLAGS ?= $(CCFLAGS) ;
5760

5861
#
@@ -122,26 +125,30 @@ rule DylanLibrary image : version {
122125
# Link a Dylan library as a shared library or executable image.
123126

124127
local _dll = [ FDLLName $(image) ] ;
125-
local _lib = [ FLIBName $(image) ] ;
128+
local _ulib = [ FULIBName $(image) ] ;
129+
local _lflag = [ FLIBFlag $(image) ] ;
126130
local _exe = [ FEXEName $(image) ] ;
131+
local _uexe = $(_exe:G=unify) ;
127132

128133
# Here we save the name and search directory of the DLL for this library.
129134

130135
_dll_$(image[1]:L) = $(_dll) ;
131-
_lib_$(image[1]:L) = $(_lib) ;
136+
_ulib_$(image[1]:L) = $(_ulib) ;
137+
_lflag_$(image[1]:L) = $(_lflag) ;
132138
if ! $(SYSTEM) && ! $(PERSONAL_ROOT) {
133139
_dir_$(image[1]:L) = $(LIBDIR) ;
134140
}
135141

136142
# Shared libraries and executable images
137143

138-
MakeLocate $(_dll) : $(LIBDIR) ;
144+
MakeLocate $(_dll) $(_ulib) : $(LIBDIR) ;
139145
MakeLocate $(_exe) : $(BINDIR) ;
146+
MakeLocate $(_uexe) : $(SBINDIR) ;
140147

141148
# Initial library search path
142149

143150
LIBPATH on $(_dll) = $(PERSONAL_LIBDIR) ;
144-
LIBPATH on $(_exe) = $(PERSONAL_LIBDIR:E=$(LIBDIR)) ;
151+
LIBPATH on $(_exe) $(_uexe) = $(PERSONAL_LIBDIR:E=$(LIBDIR)) ;
145152

146153
# Install needed runtime libraries locally
147154
if $(image[1]:L) = dylan {
@@ -182,10 +189,16 @@ rule DylanLibrary image : version {
182189
SEARCH on $(_obj) $(_asm) = $(SEARCH_SOURCE) ;
183190

184191
Depends $(_exe) : $(_dll) ;
185-
LINKLIBS on $(_exe) += $(_lib) ;
186-
LINKFLAGS on $(_exe) = $(LINKFLAGS) $(LINKFLAGSEXE) ;
192+
LINKLIBS on $(_exe) += $(_lflag) ;
193+
LINKFLAGS on $(_exe) $(_uexe) = $(LINKFLAGS) $(LINKFLAGSEXE) ;
187194
LinkEXE $(_exe) : $(_obj) ;
188195

196+
# Dylan glue must appear first in the statically-linked executable
197+
# so that the system initializations are performed in the right
198+
# order
199+
local _glue = _glue$(SUFOUT) ;
200+
UnifyEXE $(_uexe) : $(_glue:G=dylan) $(_obj) $(_ulib) ;
201+
189202
if $(COMPILER_BACK_END) = c {
190203
LINKFLAGS on $(_exe) += [ on $(_exe) FIncludes $(HDRS) ] ;
191204
}
@@ -196,10 +209,11 @@ rule DylanLibrary image : version {
196209
if ! $(PARENT) {
197210
Depends dll : $(_dll) ;
198211
Depends exe : $(_exe) ;
212+
Depends unify-exe : $(_uexe) ;
199213

200-
Clean clean : $(_dll) $(_exe) $(_mkf) $(_obj) $(_asm) ;
214+
Clean clean : $(_dll) $(_exe) $(_uexe) $(_mkf) $(_obj) $(_asm) ;
201215
}
202-
Clean clean-all : $(_dll) $(_exe) $(_mkf) $(_obj) $(_asm) ;
216+
Clean clean-all : $(_dll) $(_exe) $(_uexe) $(_mkf) $(_obj) $(_asm) ;
203217

204218
# Mark the library version
205219

@@ -214,6 +228,7 @@ rule DylanLibraryFiles image : files {
214228
# Link Dylan-derived object files into the resulting shared library.
215229
if ! $(SYSTEM) {
216230
local _dll = [ FDLLName $(image) ] ;
231+
local _ulib = [ FULIBName $(image) ] ;
217232

218233
local _out = [ FGristFiles _glue$(SUFOUT) $(files:S=$(SUFOUT)) ] ;
219234
local _asm = [ FGristFiles _glue$(SUFASM) $(files:S=$(SUFASM)) ] ;
@@ -234,6 +249,7 @@ rule DylanLibraryFiles image : files {
234249
Cc $(_mobj) : $(_i) ;
235250
}
236251
LinkDLL $(_dll) : $(_mobj) ;
252+
UnifyArchive $(_ulib) : $(_mobj) ;
237253
}
238254
} else {
239255
LinkDLL $(_dll) : $(_out) ;
@@ -254,9 +270,10 @@ rule DylanLibraryLinkerOptions image : options {
254270

255271
local _dll = [ FDLLName $(image) ] ;
256272
local _exe = [ FEXEName $(image) ] ;
273+
local _uexe = $(_exe:G=unify) ;
257274

258-
LINKLIBS on $(_dll) += $(options) ;
259-
LINKLIBS on $(_exe) += $(options) ;
275+
LINKLIBS on $(_dll) $(_exe) $(_uexe) += $(options) ;
276+
_uopt_$(image[1]:L) += $(options) ;
260277
}
261278

262279
rule DylanLibraryBaseAddress image : address {
@@ -305,8 +322,10 @@ rule DylanLibraryCObjects image : objects {
305322
# Link C (or other externally-derived) object files into the shared library.
306323
if ! $(SYSTEM) {
307324
local _dll = [ FDLLName $(image) ] ;
325+
local _ulib = [ FULIBName $(image) ] ;
308326
SEARCH on $(objects) = $(SEARCH_SOURCE) ;
309327
LinkDLL $(_dll) : $(objects) ;
328+
UnifyArchive $(_ulib) : $(objects) ;
310329
}
311330
}
312331

@@ -317,6 +336,7 @@ rule DylanLibraryCSources image : sources {
317336
# Link C source files into the shared library.
318337
if ! $(SYSTEM) {
319338
local _dll = [ FDLLName $(image) ] ;
339+
local _ulib = [ FULIBName $(image) ] ;
320340
local _exe = [ FEXEName $(image) ] ;
321341

322342
local _i ;
@@ -328,6 +348,7 @@ rule DylanLibraryCSources image : sources {
328348
Cc $(_obj) : $(_i) ;
329349

330350
LinkDLL $(_dll) : $(_obj) ;
351+
UnifyArchive $(_ulib) : $(_obj) ;
331352
}
332353
}
333354
}
@@ -426,18 +447,28 @@ rule DylanLibraryUses image : library : dir {
426447
}
427448

428449
DylanLibraryClosure $(image) : $(library:L) ;
450+
451+
local _exe = [ FEXEName $(image) ] ;
452+
local _uexe = $(_exe:G=unify) ;
453+
for _i in $(_use_$(image[1]:L)) {
454+
Depends $(_uexe) : $(_ulib_$(_i)) ;
455+
NEEDLIBS on $(_uexe) += $(_ulib_$(_i)) ;
456+
LINKLIBS on $(_uexe) += $(_clib_$(_i)) $(_uopt_$(_i)) ;
457+
}
429458
}
430459

431460
rule DylanLibraryClosure image : libraries {
461+
#Echo DylanLibraryClosure $(image) ":" $(libraries) ;
432462
local _dll = [ FDLLName $(image) ] ;
433463
local _exe = [ FEXEName $(image) ] ;
434464

435465
local _i ;
436466
for _i in $(libraries) {
437467
if ! $(_i) in $(_use_$(image[1]:L)) {
438468
_use_$(image[1]:L) += $(_i) ;
469+
439470
Depends $(_dll) $(_exe) : $(_dll_$(_i)) ;
440-
LINKLIBS on $(_dll) $(_exe) += $(_lib_$(_i)) $(_clib_$(_i)) ;
471+
LINKLIBS on $(_dll) $(_exe) += $(_lflag_$(_i)) $(_clib_$(_i)) ;
441472
LIBPATH on $(_dll) $(_exe) += $(_dir_$(_i)) ;
442473

443474
DylanLibraryClosure $(image) : $(_use_$(_i)) ;
@@ -460,6 +491,15 @@ actions together LinkDLL bind NEEDLIBS {
460491
$(STRIP) -s $(<:Q)
461492
}
462493

494+
rule UnifyArchive {
495+
#Echo UnifyArchive $(<) ":" $(>) ;
496+
Depends $(<) : $(>) ;
497+
}
498+
499+
actions together UnifyArchive {
500+
$(AR) $(<:Q) $(>:Q)
501+
}
502+
463503
rule LinkEXE {
464504
#Echo LinkEXE $(<) ":" $(>) ;
465505
Depends $(<) : $(>) ;
@@ -472,6 +512,18 @@ actions LinkEXE bind NEEDLIBS {
472512
$(STRIP) -s $(<:Q)
473513
}
474514

515+
rule UnifyEXE {
516+
#Echo UnifyEXE $(<) ":" $(>) ;
517+
Depends $(<) : $(>) ;
518+
}
519+
520+
actions UnifyEXE bind NEEDLIBS {
521+
$(UNIFYLINK) -o $(<:Q) $(LINKFLAGS) $(>:Q) -L"$(LIBPATH)" -Wl,--start-group $(NEEDLIBS:Q) $(LINKLIBS) -Wl,--end-group
522+
$(OBJCOPY) $(<:Q) $(<:Q).dbg
523+
$(OBJCOPY) --add-gnu-debuglink=$(<:Q).dbg $(<:Q)
524+
$(STRIP) -s $(<:Q)
525+
}
526+
475527
#
476528
# Utility rules
477529
#
@@ -485,6 +537,18 @@ rule FDLLName {
485537
}
486538

487539
rule FLIBName {
540+
if $(<[2]) {
541+
return lib$(<[2]:LS=$(SUFLIB)) ;
542+
} else {
543+
return lib$(<[1]:LS=$(SUFLIB)) ;
544+
}
545+
}
546+
547+
rule FULIBName {
548+
return [ FLIBName $(<),unify ] ;
549+
}
550+
551+
rule FLIBFlag {
488552
if $(<[2]) {
489553
return -l$(<[2]:L) ;
490554
} else {

sources/jamfiles/riscv64-linux-build.jam

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
2323
#
2424
# Overrides/redefinitions
2525
#
26-
rtclibs += -lpthread -lrt ;
26+
rtclibs += -lpthread -ldl -lrt ;

sources/jamfiles/shared-darwin-build.jam

+6
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ actions LinkEXE bind NEEDLIBS {
3434
$(DSYMUTIL) $(<:Q) &&
3535
$(STRIP) -S $(<:Q)
3636
}
37+
38+
actions UnifyEXE bind NEEDLIBS {
39+
$(UNIFYLINK) -o $(<:Q) $(LINKFLAGS) $(>:Q) -L"$(LIBPATH)" $(NEEDLIBS:Q) $(LINKLIBS) &&
40+
$(DSYMUTIL) $(<:Q) &&
41+
$(STRIP) -S $(<:Q)
42+
}

sources/jamfiles/x86_64-linux-build.jam

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ include $(SYSTEM_BUILD_SCRIPTS)/posix-build.jam ;
2424
#
2525
# Overrides/redefinitions
2626
#
27-
rtclibs += -lpthread -lrt ;
27+
rtclibs += -lpthread -ldl -lrt ;

sources/lib/release-info/common-info.dylan

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ define constant $help-filename = "opendylan.chm";
2222
/// Release constants
2323
define constant $release-product-name = "Open Dylan";
2424
define constant $release-product-identifier = "opendylan";
25-
define constant $release-version = "2021.1pre";
25+
define constant $release-version = "2022.1pre";
2626

2727
define constant $release-copyright
2828
= "Copyright (c) 1997-2004, Functional Objects, Inc.\n"

0 commit comments

Comments
 (0)