[MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
--------------------+-----------------------
 Reporter:  akimd   |      Owner:
     Type:  defect  |     Status:  new
 Priority:  Normal  |  Milestone:
Component:  ports   |    Version:  2.3.5
 Keywords:          |       Port:  clang-3.9
--------------------+-----------------------
 Hi,

 It seems that clang expects the libraries for C++ to be at another place:

 {{{
 $ cat foo.cc
 12
 int main()
 {
   return 1 << 34;
 }

 $ clang++-mp-3.9 -fsanitize=undefined foo.cc
 foo.cc:3:12: warning: shift count >= width of type [-Wshift-count-
 overflow]
   return 1 << 34;
            ^  ~~
 1 warning generated.
 $ ./a.out
 dyld: Library not loaded:
 /opt/local/libexec/llvm-3.9/lib/libclang_rt.ubsan_osx_dynamic.dylib
   Referenced from: /private/tmp/./a.out
   Reason: image not found
 zsh: abort (core dumped)  ./a.out
 $ ls  /opt/local/libexec/llvm-3.9/lib/libclang_*
 zsh: no matches found: /opt/local/libexec/llvm-3.9/lib/libclang_*
 $ ls /opt/local/libexec/llvm-3.9/lib/clang/3.9.1/lib/darwin
 libclang_rt.10.4.a                      libclang_rt.eprintf.a
 libclang_rt.safestack_osx.a             libclang_rt.tsan_osx_dynamic.dylib
 libclang_rt.asan_osx_dynamic.dylib      libclang_rt.osx.a
 libclang_rt.stats_client_osx.a
 libclang_rt.ubsan_osx_dynamic.dylib
 libclang_rt.cc_kext.a                   libclang_rt.profile_osx.a
 libclang_rt.stats_osx_dynamic.dylib
 $ DYLD_LIBRARY_PATH=/opt/local/libexec/llvm-3.9/lib/clang/3.9.1/lib/darwin
 ./a.out
 foo.cc:3:12: runtime error: shift exponent 34 is too large for 32-bit type
 'int'
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/53299>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+-------------------
  Reporter:  akimd      |      Owner:
      Type:  defect     |     Status:  new
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+-------------------

Comment (by akimd):

 Note that SIP makes this even more troublesome: when running a program
 such as `./configure`, DYLD_ variables are not preserved.  Workaronds
 makes things more complex, and less portable.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------
Changes (by mf2k):

 * status:  new => assigned
 * cc: jeremyhu@…, larryv@… (removed)
 * cc: larryv (added)
 * owner:   => jeremyhu


--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:2>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by jeremyhu):

 Yeah, looks like the dylib ID is wrong:

 {{{
 ~ $ otool -D
 /opt/local/libexec/llvm-3.9/lib/clang/3.9.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
 /opt/local/libexec/llvm-3.9/lib/clang/3.9.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:
 /opt/local/libexec/llvm-3.9/lib/libclang_rt.asan_osx_dynamic.dylib
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by jeremyhu):

 The executable's LC_RPATH is correct.

 {{{
 Load command 14
           cmd LC_RPATH
       cmdsize 32
          path @executable_path (offset 12)
 Load command 15
           cmd LC_RPATH
       cmdsize 80
          path
 /opt/local/libexec/llvm-3.9/bin/../lib/clang/3.9.1/lib/darwin (offset 12)
 }}}

 We just need to figure out:

 1) Why aren't the sanitizer dylibs getting installed with an @rpath-
 relative dylib id.
 2) Optionally, figure out why the fixed path dylib id doesn't match the
 install path either.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by akimd):

 Ping?  Not being able to use any of the sanitizers is disabling.  Thanks!

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by jeremyhu):

 You can use them just fine using DYLD_INSERT_LIBRARIES.

 If you can answer either of those questions above and provide a solution,
 I'll integrate it.  Otherwise, you're going to have to wait until someone
 else has time to look into the issue and provide such a solution.  I
 currently don't have resources for that and won't for at least another
 month.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by hmijail):

 Just wanted to note that, as akimd mentioned already, the DYLD_*
 environment variables getting cleared by SIP make working around this
 issue quite difficult.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:7>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by akimd):

 Hi all,

 FWIW, there is an easy workaround (that the package should implement
 imho): install a symlink.  I've been using it successfully for quite a
 while now, with different versions of clang-*.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:8>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by hmijail):

 Issue still present in clang 5.0.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:9>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #53299: clang-3.9: sanitizer libraries not at the right place

MacPorts
In reply to this post by MacPorts
#53299: clang-3.9: sanitizer libraries not at the right place
------------------------+----------------------
  Reporter:  akimd      |      Owner:  jeremyhu
      Type:  defect     |     Status:  assigned
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:  2.3.5
Resolution:             |   Keywords:
      Port:  clang-3.9  |
------------------------+----------------------

Comment (by jeremyhu):

 Yes, and I unfortunately don't see having time to get around to this issue
 any time soon, but if someone is able to provide a patch or can answer my
 points in comment #4, that would help.

--
Ticket URL: <https://trac.macports.org/ticket/53299#comment:10>
MacPorts <https://www.macports.org/>
Ports system for macOS