mold icon indicating copy to clipboard operation
mold copied to clipboard

mold fails to build with lto and -Werror=odr

Open kostadinsh opened this issue 3 years ago • 2 comments

mold fails to build with lto and -Werror=odr enabled on Gentoo gcc version: 12.2.0 complete build log

   31 | enum class exception_id {
      | 
/var/tmp/portage/sys-devel/mold-1.4.1/work/mold-1.4.1/third-party/tbb/src/tbb/../../include/oneapi/tbb/detail/_exception.h:31: note: an enum with different value name is defined in another translation unit
   31 | enum class exception_id {
      | 
/var/tmp/portage/sys-devel/mold-1.4.1/work/mold-1.4.1/third-party/tbb/src/tbb/../../include/tbb/../oneapi/tbb/detail/_exception.h:47: note: name ‘last_entry’ differs from name ‘bad_task_handle’ defined in another translation unit
   47 |     last_entry
      | 
/var/tmp/portage/sys-devel/mold-1.4.1/work/mold-1.4.1/third-party/tbb/src/tbb/../../include/oneapi/tbb/detail/_exception.h:44: note: mismatching definition
   44 |     bad_task_handle,
      | 
/var/tmp/portage/sys-devel/mold-1.4.1/work/mold-1.4.1/third-party/tbb/src/tbb/../../include/tbb/../oneapi/tbb/global_control.h:59: error: type ‘tbb::detail::d1::global_control::parameter’ violates the C++ One Definition Rule [-Werror=odr]```


kostadinsh avatar Aug 26 '22 15:08 kostadinsh

It looks like it is an error of OneTBB. What if you build only libtbb with -Werror=odr?

rui314 avatar Aug 29 '22 07:08 rui314

Yes, it's problem in OneTBB:

enum class exception_id {
    bad_alloc = 1,
    bad_last_alloc,
    user_abort,
    nonpositive_step,
    out_of_range,
    reservation_length_error,
    missing_wait,
    invalid_load_factor,
    invalid_key,
    bad_tagged_msg_cast,
    unsafe_wait,
#if __TBB_PREVIEW_TASK_GROUP_EXTENSIONS
    bad_task_handle,
    bad_task_handle_wrong_task_group,
#endif // __TBB_PREVIEW_TASK_GROUP_EXTENSIONS
    last_entry
};

Apparently, some units are built with __TBB_PREVIEW_TASK_GROUP_EXTENSIONS and some w/o. Please report it to upstream.

marxin avatar Aug 30 '22 12:08 marxin

This was fixed upstream in Dec 2021, in https://github.com/oneapi-src/oneTBB/commit/74b7fc748bffb699a60bdedc867a1e208e50bd2a (part of https://github.com/oneapi-src/oneTBB/pull/668).

MatthewGentoo avatar Nov 09 '22 07:11 MatthewGentoo

Then, please close this.

marxin avatar Nov 09 '22 08:11 marxin

On 09/11/2022 08:41, Martin Liška wrote:

Then, please close this.

It was fixed upstream but it's still an issue in the vendored copy of mold.

MatthewGentoo avatar Nov 10 '22 09:11 MatthewGentoo

I'll upgrade it to https://github.com/oneapi-src/oneTBB/releases/tag/v2021.7.0 before making the next release.

rui314 avatar Nov 10 '22 09:11 rui314