shithub: mc

Download patch

ref: b635e2c01451f39c4468f2b6a43e57902dee99f1
parent: bd389067cb68d0d7b4c55db95f1b8021f1d95524
author: Ori Bernstein <[email protected]>
date: Wed Oct 24 10:21:05 EDT 2012

Search local libs before system libs.

--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -275,9 +275,13 @@
 
     args = NULL;
     nargs = 0;
+
+    /* ld -o outfile */
     lappend(&args, &nargs, strdup(ld));
     lappend(&args, &nargs, strdup("-o"));
     lappend(&args, &nargs, strdup(binname));
+
+    /* ld -o outfile foo.o bar.o baz.o */
     for (i = 0; i < nfiles; i++) {
         if (hassuffix(files[i], ".myr"))
             swapsuffix(buf, sizeof buf, files[i], ".myr", ".o");
@@ -287,12 +291,16 @@
             die("Unknown file type %s", files[i]);
         lappend(&args, &nargs, strdup(buf));
     }
-    snprintf(buf, sizeof buf, "-L%s%s", Instroot, "/lib/myr");
-    lappend(&args, &nargs, strdup(buf));
+
+    /* ld -o outfile foo.o bar.o baz.o -L/path1 -L/path2 */
     for (i = 0; i < nincpaths; i++) {
         snprintf(buf, sizeof buf, "-L%s", incpaths[i]);
         lappend(&args, &nargs, strdup(buf));
     }
+    snprintf(buf, sizeof buf, "-L%s%s", Instroot, "/lib/myr");
+    lappend(&args, &nargs, strdup(buf));
+
+    /* ld -o outfile foo.o bar.o baz.o -L/path1 -L/path2 -llib1 -llib2*/
     for (i = 0; i < nlibs; i++) {
         snprintf(buf, sizeof buf, "-l%s", libs[i]);
         lappend(&args, &nargs, strdup(buf));