<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - lib/tsan/go/buildgo.sh does not respect LDFLAGS when linking test binary"
   href="https://llvm.org/bugs/show_bug.cgi?id=27597">27597</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lib/tsan/go/buildgo.sh does not respect LDFLAGS when linking test binary
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>michael.hudson@canonical.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>buildgo.sh fails on Ubuntu 15.10 because the toolchain defaults to PIE there
currently:

(yakkety-amd64)root@aeglos:/root/trunk/lib/tsan/go# ./buildgo.sh 
gcc gotsan.cc -c -o ./race_linux_amd64.syso -I../rtl -I../..
-I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall
-fno-exceptions -fno-rtti -DSANITIZER_GO
-DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 -fPIC -ffreestanding
-Wno-maybe-uninitialized -Wno-unused-const-variable -Werror
-Wno-unknown-warning-option -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer
==27227==ERROR: ThreadSanitizer failed to allocate 0x4000 (16384) bytes at
address 1778c48e40000 (errno: 12)
Segmentation fault (core dumped)

Fixing this requires passing -no-pie to the link, but doing this properly is a
bit of a pain because support for the -no-pie flag is pretty new. It would be
easier for me to work around if linking the test executable respected the
LDFLAGS environment variable:

--- a/lib/tsan/go/buildgo.sh
+++ b/lib/tsan/go/buildgo.sh
@@ -121,7 +121,7 @@
 fi
 $CC $DIR/gotsan.cc -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS

-$CC test.c $DIR/race_$SUFFIX.syso -m64 -o $DIR/test $OSLDFLAGS
+$CC test.c $DIR/race_$SUFFIX.syso -m64 -o $DIR/test $OSLDFLAGS $LDFLAGS

 export GORACE="exitcode=0 atexit_sleep_ms=0"
 if [ "$SILENT" != "1" ]; then

Would you consider such a change?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>