]> Cypherpunks repositories - gostls13.git/commitdiff
race: linker changes
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 18 Sep 2012 21:05:25 +0000 (01:05 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 18 Sep 2012 21:05:25 +0000 (01:05 +0400)
This is the second part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
This change makes the linker emit dependency on runtime/race package when supplied with -b flag.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6488074

src/cmd/ld/doc.go
src/cmd/ld/lib.c

index e99e504668f1dffd7e617b3e4a3bd238394cacb7..539448d27645d08fb79d306ee51e54eb249143f1 100644 (file)
@@ -56,5 +56,7 @@ Options new in this version:
                Set the value of an otherwise uninitialized string variable.
                The symbol name should be of the form importpath.name,
                as displayed in the symbol table printed by "go tool nm".
+       -b
+               Link with race detection libraries.
 */
 package documentation
index 2026707c2fee5a43ccf464e5a74306369a38d54b..135426473fbb22379039e19663bace55ece018f3 100644 (file)
@@ -72,6 +72,8 @@ Lflag(char *arg)
 void
 libinit(void)
 {
+       char *race;
+
        fmtinstall('i', iconv);
        fmtinstall('Y', Yconv);
        fmtinstall('Z', Zconv);
@@ -80,7 +82,10 @@ libinit(void)
                print("goarch is not known: %s\n", goarch);
 
        // add goroot to the end of the libdir list.
-       Lflag(smprint("%s/pkg/%s_%s", goroot, goos, goarch));
+       race = "";
+       if(debug['b'])
+               race = "_race";
+       Lflag(smprint("%s/pkg/%s_%s%s", goroot, goos, goarch, race));
 
        // Unix doesn't like it when we write to a running (or, sometimes,
        // recently run) binary, so remove the output file before writing it.
@@ -281,6 +286,8 @@ loadlib(void)
        loadinternal("runtime");
        if(thechar == '5')
                loadinternal("math");
+       if(debug['b'])
+               loadinternal("runtime/race");
 
        for(i=0; i<libraryp; i++) {
                if(debug['v'])