summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-01 00:50:08 -0700
committerOri Bernstein <ori@eigenstate.org>2015-10-01 22:35:32 -0700
commitd7d95f9f1db8434f40d5ac3c81ba486223e3893b (patch)
tree854c7831284c9881afb1528a669e0587a7879114 /mbld
parentd60e706a5f499863320b9359519438c62a4df303 (diff)
downloadmc-d7d95f9f1db8434f40d5ac3c81ba486223e3893b.tar.gz
Add muse support for C linking on Linux.
We know know about foo.glue.c, which will attempt to link in libfoo. We don't do anything about dependencies of libfoo yet.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/build.myr11
-rw-r--r--mbld/deps.myr18
-rw-r--r--mbld/main.myr5
-rw-r--r--mbld/types.myr1
-rw-r--r--mbld/util.myr8
5 files changed, 31 insertions, 12 deletions
diff --git a/mbld/build.myr b/mbld/build.myr
index f37541b..8f52b7a 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -252,6 +252,14 @@ const compile = {src, incs
cmd = std.slpush(cmd, src)
run(cmd)
std.slfree(o)
+ elif std.hassuffix(src, ".glue.c")
+ o = srcswapsuffix(src, config.Objsuffix)
+ cmd = std.slpush(cmd, "cc")
+ cmd = std.slpush(cmd,"-c")
+ cmd = std.slpush(cmd,"-o")
+ cmd = std.slpush(cmd, o)
+ cmd = std.slpush(cmd, src)
+ run(cmd)
else
std.fatal("Unknown file type for {}\n", src)
;;
@@ -292,6 +300,9 @@ const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extralibs
if std.sleq(opt_sys, "osx")
cmd = std.slpush(cmd, std.sldup("-macosx_version_min"))
cmd = std.slpush(cmd, std.sldup("10.6"))
+ elif std.sleq(opt_sys, "linux") && dg.dynamic
+ cmd = std.slpush(cmd, std.sldup("-dynamic-linker"))
+ cmd = std.slpush(cmd, std.sldup("/lib64/ld-linux-x86-64.so.2"))
;;
run(cmd)
diff --git a/mbld/deps.myr b/mbld/deps.myr
index e269250..710ab70 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -9,15 +9,20 @@ use "util.use"
pkg bld =
const myrdeps : (b : build#, mt : myrtarg#, doclean : bool, addsrc : bool -> depgraph#)
-
- /* a bit ugly: initialized from main() */
- var usepat : regex.regex#
;;
const Abiversion = 8
var usepat : regex.regex#
+const __init__ = {
+ match regex.compile("^\\s*use\\s+((\\<\\S+\\>)|\"(\\S+)\").*")
+ | `std.Ok re: usepat = re
+ | `std.Fail f: std.fatal("Failed to compile use pattern regex\n")
+ ;;
+}
+
+
type dep = union
`Local (byte[:], int)
`Lib (byte[:], int)
@@ -33,7 +38,7 @@ type depscan = struct
;;
const myrdeps = {b, mt, doclean, addsrc
- var objs, uses, srcs
+ var objs, uses, srcs, clib
var out, useout
var dg : depgraph#
var ds : depscan
@@ -47,6 +52,7 @@ const myrdeps = {b, mt, doclean, addsrc
.updated = std.mkht(std.strhash, std.streq),
.seen = std.mkht(std.strhash, std.streq),
.done = std.mkht(std.strhash, std.streq),
+ .dynamic = false,
])
/* direct dependencies of binary */
if mt.islib
@@ -74,6 +80,10 @@ const myrdeps = {b, mt, doclean, addsrc
if std.hassuffix(srcs[i], ".myr")
std.htput(dg.input, uses[i], srcs[i])
pushdep(dg, srcs[i], uses[i])
+ elif std.hassuffix(srcs[i], ".glue.c")
+ clib = swapsuffix(srcs[i], ".glue.c", "")
+ std.htput(dg.libs, clib, [][:])
+ dg.dynamic = true
;;
;;
diff --git a/mbld/main.myr b/mbld/main.myr
index ab96986..92c25ee 100644
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -79,11 +79,6 @@ const main = {args : byte[:][:]
bld.opt_incpaths = std.slpush(bld.opt_incpaths, libpath)
;;
- match regex.compile("^\\s*use\\s+((\\<\\S+\\>)|\"(\\S+)\").*")
- | `std.Ok re: bld.usepat = re
- | `std.Fail f: std.fatal("Failed to compile use pattern regex\n")
- ;;
-
b = mkbuild(tags)
if targname.len != 0
mt = [
diff --git a/mbld/types.myr b/mbld/types.myr
index 1756f1f..cd9bf27 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -70,5 +70,6 @@ pkg bld =
updated : std.htab(byte[:], bool)#
seen : std.htab(byte[:], bool)#
done : std.htab(byte[:], bool)#
+ dynamic : bool
;;
;;
diff --git a/mbld/util.myr b/mbld/util.myr
index 511f208..c5da448 100644
--- a/mbld/util.myr
+++ b/mbld/util.myr
@@ -51,7 +51,7 @@ const srcsplit = {src
platf = ""
suff = ""
- match std.strrfind(src, ".")
+ match std.strfind(src, ".")
| `std.Some i:
suff = src[i:]
src = src[:i]
@@ -80,10 +80,12 @@ const srcswapsuffix = {src, new
var base, platf, suff
(base, platf, suff) = srcsplit(src)
- if std.sleq(suff, ".myr")
+ if std.hassuffix(suff, ".myr")
-> std.strcat(base, new)
- elif std.sleq(suff, ".s")
+ elif std.hassuffix(suff, ".s")
-> std.strcat(base, new)
+ elif std.hassuffix(suff, ".glue.c")
+ -> std.strjoin([base, ".glue", new][:], "")
else
std.fatal("unrecognized source {}\n", src)
;;