diff options
author | Ori Bernstein <ori@eigenstate.org> | 2018-01-16 10:04:07 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2018-01-16 10:04:07 -0800 |
commit | 8f8899df9181abbde98ca28f8f7a8ff39cf17146 (patch) | |
tree | 14517ce08006226d026c26b359c0adc80784afe7 | |
parent | ac6c06f906d356b0004ed450558dd890c7057fbf (diff) | |
parent | 4db2895318842a451a5036652ea9373667a603b1 (diff) | |
download | mc-8f8899df9181abbde98ca28f8f7a8ff39cf17146.tar.gz |
Merge branch 'clink-obsd' of https://github.com/moreais/mc into trait-syntaxtrait-syntax
-rwxr-xr-x | configure | 9 | ||||
-rw-r--r-- | mbld/config+plan9-x64.myr | 1 | ||||
-rw-r--r-- | mbld/deps.myr | 13 | ||||
-rw-r--r-- | mbld/libs.myr | 16 | ||||
-rw-r--r-- | rt/start-openbsd.s | 12 |
5 files changed, 41 insertions, 10 deletions
@@ -49,6 +49,8 @@ case $OS in echo export INST_MAN=$prefix/share/man/man >> config.mk echo 'const Sys = "Linux"' >> mbld/config.myr echo 'const Linkcmd = ["ld"]' >> mbld/config.myr + echo 'const Dlflags = ["-dynamic-linker",' \ + '"/lib64/ld-linux-x86-64.so.2"]' >> mbld/config.myr echo "const Manpath = \"share/man/man\"" >> mbld/config.myr ;; *Darwin*) @@ -64,6 +66,7 @@ case $OS in '"-macosx_version_min", "10.6",'\ ']' >> mbld/config.myr echo "const Manpath = \"share/man/man\"" >> mbld/config.myr + echo 'const Dlflags : byte[:][:] = [][:]' >> mbld/config.myr env='[("MACOSX_DEPLOYMENT_TARGET", "10.6")][:]' ;; *FreeBSD*) @@ -71,6 +74,7 @@ case $OS in echo export INST_MAN=$prefix/man/man >> config.mk echo 'const Sys = "FreeBSD"' >> mbld/config.myr echo 'const Linkcmd = ["ld"]' >> mbld/config.myr + echo 'const Dlflags : byte[:][:] = [][:]' >> mbld/config.myr echo "const Manpath = \"man/man\"" >> mbld/config.myr ;; *NetBSD*) @@ -78,13 +82,16 @@ case $OS in echo export INST_MAN=$prefix/man/man >> config.mk echo 'const Sys = "NetBSD"' >> mbld/config.myr echo 'const Linkcmd = ["ld"]' >> mbld/config.myr + echo 'const Dlflags : byte[:][:] = [][:]' >> mbld/config.myr echo "const Manpath = \"man/man\"" >> mbld/config.myr ;; *OpenBSD*) echo 'export SYS=openbsd' >> config.mk echo export INST_MAN=$prefix/man/man >> config.mk echo 'const Sys = "OpenBSD"' >> mbld/config.myr - echo 'const Linkcmd = ["ld", "-static", "-nopie"]' >> mbld/config.myr + echo 'const Linkcmd = ["ld", "-nopie"]' >> mbld/config.myr + echo 'const Dlflags = ["-dynamic-linker",' \ + '"/usr/libexec/ld.so"]' >> mbld/config.myr echo "const Manpath = \"man/man\"" >> mbld/config.myr ;; *) diff --git a/mbld/config+plan9-x64.myr b/mbld/config+plan9-x64.myr index b13fedc..e246d4d 100644 --- a/mbld/config+plan9-x64.myr +++ b/mbld/config+plan9-x64.myr @@ -4,6 +4,7 @@ pkg config = const Sys = "Plan9" const Objsuffix = ".6" const Linkcmd = ["6l", "-l"] + const Dlflags : byte[:][:] = [][:] const Arcmd = ["ar", "u"] const Ascmd = ["6a"] const Directlib = true diff --git a/mbld/deps.myr b/mbld/deps.myr index ab90890..cae46b1 100644 --- a/mbld/deps.myr +++ b/mbld/deps.myr @@ -427,6 +427,8 @@ const arcmd = {b, n, mt, ar } const linkcmd = {b, n, mt, bin, libs, dynlibs, istest + var dynlink + for c : config.Linkcmd std.slpush(&n.cmd, std.sldup(c)) ;; @@ -451,18 +453,21 @@ const linkcmd = {b, n, mt, bin, libs, dynlibs, istest std.slpush(&n.cmd, std.sldup(o)) ;; - addlibs(b, &n.cmd, libs, mt.incpath) + dynlink = addlibs(b, &n.cmd, libs, mt.incpath) || mt.isdyn for l : dynlibs std.slpush(&n.cmd, std.fmt("-l{}", l)) ;; + if dynlink + for f : config.Dlflags + std.slpush(&n.cmd, std.sldup(f)) + ;; + ;; + /* OSX warns if we don't add a version */ if std.sleq(opt_sys, "osx") std.slpush(&n.cmd, std.sldup("-macosx_version_min")) std.slpush(&n.cmd, std.sldup("10.6")) - elif std.sleq(opt_sys, "linux") && mt.isdyn - std.slpush(&n.cmd, std.sldup("-dynamic-linker")) - std.slpush(&n.cmd, std.sldup("/lib64/ld-linux-x86-64.so.2")) ;; } diff --git a/mbld/libs.myr b/mbld/libs.myr index b29becb..9652c15 100644 --- a/mbld/libs.myr +++ b/mbld/libs.myr @@ -9,7 +9,7 @@ pkg bld = const addlibs : (b : build#, \ sl : byte[:][:]#, \ libs : byte[:][:], \ - incs : byte[:][:] -> void) + incs : byte[:][:] -> bool) const builtlib : (b : build#, \ lt : myrtarg#, \ @@ -117,6 +117,7 @@ const openlib = {lib, targ, incs const addlibs = {b, sl, libs, incs var added, diradded, looped + var dynlink var lo added = std.mkht() @@ -124,8 +125,9 @@ const addlibs = {b, sl, libs, incs diradded = std.mkht() lo = sl#.len + dynlink = false for l : libs - addlib(b, sl, l, added, diradded, looped) + dynlink = addlib(b, sl, l, added, diradded, looped, dynlink) ;; for var i = 0; i < sl#[lo:].len/2; i++ std.swap(&sl#[lo+i], &sl#[sl#.len - i - 1]) @@ -134,9 +136,11 @@ const addlibs = {b, sl, libs, incs std.htfree(diradded) std.htfree(looped) std.htfree(added) + + -> dynlink } -const addlib = {b, sl, lib, added, diradded, looped +const addlib = {b, sl, lib, added, diradded, looped, dl var ar if std.hthas(looped, lib) @@ -146,12 +150,13 @@ const addlib = {b, sl, lib, added, diradded, looped match std.htget(b.libs, lib) | `std.None: std.slpush(sl, std.fmt("-l{}", lib)) + dl = true | `std.Some ld: for l : ld.dep - addlib(b, sl, l, added, diradded, looped) + dl = addlib(b, sl, l, added, diradded, looped, dl) ;; for l : ld.dyndep - addlib(b, sl, l, added, diradded, looped) + dl = addlib(b, sl, l, added, diradded, looped, dl) ;; if !std.hthas(added, lib) if config.Directlib @@ -169,6 +174,7 @@ const addlib = {b, sl, lib, added, diradded, looped ;; ;; std.htdel(looped, lib) + -> dl } diff --git a/rt/start-openbsd.s b/rt/start-openbsd.s index 9fd8610..c0e061a 100644 --- a/rt/start-openbsd.s +++ b/rt/start-openbsd.s @@ -60,6 +60,18 @@ _start: movq $1,%rax syscall +/* + * provide __guard_local for if we are + * linking against libc + */ +.section ".openbsd.randomdata", "aw" + .global __guard_local + .hidden __guard_local + .type __guard_local, "object" + .p2align 3 +__guard_local: + .quad 0 + .size __guard_local, 8 .section ".note.openbsd.ident", "a" .p2align 2 |