Opened 6 years ago

Closed 5 years ago

#57130 closed defect (fixed)

clang-7.0: build fails in compiler-rt/lib/xray on darwin < 15 due to several issues

Reported by: kencu (Ken) Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: tehcog (tehcog)
Port: clang-7.0

Description

there are three issues building XRAY on older systems (that I have found so far).

  1. It needs thread local storage, which results in systems < darwin 11 failing.
  2. MAP_ANONYMOUS is used but undefined on older systems. This is fixed easily enough by replacing the definition with -DMAP_ANONYMOUS=MAP_ANON. I did it by adding the definition in compiler-rt/CMakeLists.txt to cover all the instances at once.
  3. error: use of undeclared identifier 'CLOCK_REALTIME'. This one may be harder to fix. There are some example replacement functions <https://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x> but I'm not sure if any of them truly offer a suitable replacement.

These issues may result in XRAY being disabled on all the non-building systems (currently darwin < 15).

When XRAY is disabled on darwin10 clang-7.0 builds through to completion (this fix is already in the Portfile restricted to darwin 10 or less <https://github.com/macports/macports-ports/commit/3f03093e264ea484508dbbcc6f8cbc14b18a23df> ).

Attachments (1)

patch-map-anonymous-replacement.diff (494 bytes) - added by kencu (Ken) 6 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 6 years ago by kencu (Ken)

Port: clang-7.0 added; clang-5.0 removed

comment:2 Changed 6 years ago by kencu (Ken)

On 10.9:

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_llvm-7.0/clang-7.0/work/llvm-7.0.0rc2.src/projects/compiler-rt/lib/xray/xray_basic_logging.cc:300:32: error: use of undeclared identifier 'CLOCK_REALTIME'
    int result = clock_gettime(CLOCK_REALTIME, &TS);
                               ^
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_llvm-7.0/clang-7.0/work/llvm-7.0.0rc2.src/projects/compiler-rt/lib/xray/xray_basic_logging.cc:320:36: error: use of undeclared identifier 'CLOCK_REALTIME'
        int result = clock_gettime(CLOCK_REALTIME, &TS);
                                   ^
2 errors generated.
make[2]: *** [projects/compiler-rt/lib/xray/CMakeFiles/RTXrayBASIC.osx.dir/xray_basic_logging.cc.o] Error 1

Changed 6 years ago by kencu (Ken)

comment:3 Changed 6 years ago by kencu (Ken)

if XRAY is disabled, clang-7.0 builds through on 10.9 without further modifications (and without the map_anonymous patch):

$ port -v installed clang-7.0
The following ports are currently installed:
  clang-7.0 @7.0.0rc2_0+analyzer+libstdcxx (active) platform='darwin 13' archs='x86_64' date='2018-09-13T23:47:36-0700'

comment:4 Changed 6 years ago by kencu (Ken)

A moderately complex replacement for clock_gettime() with an MIT license: <https://gist.github.com/alfwatt/3588c5aa1f7a1ef7a3bb>.

comment:5 Changed 6 years ago by kencu (Ken)

Here's a clock_gettime() replacement that is currently used in MacPorts, courtesy of Dave <https://github.com/macports/macports-ports/blob/master/graphics/cogl/files/patch-clock_gettime.diff>

Version 0, edited 6 years ago by kencu (Ken) (next)

comment:6 Changed 6 years ago by kencu (Ken)

Upstream bug report for MAP_ANONYMOUS issue <https://bugs.llvm.org/show_bug.cgi?id=38958>.

comment:7 Changed 6 years ago by kencu (Ken)

Upstream bug report for clock_gettime() issue <https://bugs.llvm.org/show_bug.cgi?id=38959>

comment:8 Changed 6 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Thanks for filing the upstream radars. We should just disable in on < 10.9 for now unless someone speaks up that they need it.

comment:9 Changed 6 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Owner: changed from jeremyhu to kencu

Re-assigning to Ken, so he can just update his existing patch for <10.6 instead.

comment:10 Changed 6 years ago by kencu (Ken)

Will do. To avoid commit conflicts, I'll wait until <https://github.com/macports/macports-ports/pull/2614> lands shortly.

comment:11 Changed 6 years ago by tehcog (tehcog)

Cc: tehcog added

comment:12 Changed 5 years ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed

In bafb66e16d5ed7e0b3b70b1f1caf82a5b3068463/macports-ports (master):

clang-7.0: fix build on darwin 14 and less

XRAY currently does not build on these systesm due to the
issues mentioned in the Portfile
closes: #57130

Note: See TracTickets for help on using tickets.