Project

General

Profile

Actions

Bug #10599

closed

Visibility issue with static libs on macOS

Added by Roel Standaert over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Roel Standaert
Target version:
Start date:
07/06/2022
Due date:
% Done:

100%

Estimated time:

Description

When building Wt with -DSHARED_LIBS=OFF on macOS, it outputs linking warnings like:

ld: warning: direct access in function 'Wt::Chart::WAxis::getValue(std::__1::any const&) const' from file 'src/libwt.a(WAxis.C.o)' to global weak symbol 'std::__1::__any_imp::__unique_typeinfo<Wt::WDateTime>::__id' from file 'test/CMakeFiles/test.wt.dir/chart/WChartTest.C.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

This is because we build all of our libraries with -fvisibility=hidden -fvisibility-inlines-hidden:

SET_PROPERTY(TARGET wt PROPERTY C_VISIBILITY_PRESET hidden)
SET_PROPERTY(TARGET wt PROPERTY CXX_VISIBILITY_PRESET hidden)
SET_PROPERTY(TARGET wt PROPERTY VISIBILITY_INLINES_HIDDEN YES)

Our tests are not built with the above properties. While this doesn't cause any issues on Windows or Linux, on macOS this property needs to match, otherwise, this may lead to issues.

For example, the following Sqlite3 tests are failing:

  • Sqlite3_Test_Suite.dbo_test11
  • Sqlite3_Test_Suite.dbo_test12
  • Sqlite3_Test_Suite.dbo_test25
  • Sqlite3_Test_Suite.dbo_json_sql_traits

With errors like:

ASSERTION FAILURE:
- file   : DboTest.C
- line   : 1582
- message: critical check Wt::asString(model->headerData(0)) == "id" has failed

I propose we won't set these visibility properties when building on macOS. The user may set -DCMAKE_C_VISIBILITY_PRESET=hidden -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=YES if they want to. It is then up to the user to make sure they consistently use those properties.

Maybe the issue would also be resolved if we create prelinked static libraries on macOS: https://gitlab.kitware.com/cmake/cmake/-/issues/22177 (and then declare the visibility of our symbols the same way as we do for shared libraries). At the moment this is not supported by CMake, however.

Actions #1

Updated by Roel Standaert over 2 years ago

  • Status changed from New to InProgress
Actions #2

Updated by Roel Standaert over 2 years ago

  • Status changed from InProgress to Review
  • Assignee deleted (Roel Standaert)
Actions #3

Updated by Roel Standaert over 2 years ago

  • Status changed from Review to Implemented @Emweb
  • Assignee set to Roel Standaert
  • % Done changed from 0 to 100
Actions #4

Updated by Roel Standaert over 2 years ago

  • Status changed from Implemented @Emweb to Resolved
Actions #5

Updated by Roel Standaert over 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF