Uh oh!
There was an error while loading. Please reload this page.
Enable hidden visibility by default - #190
Conversation
apolukhin
commented
Aug 20, 2018
I see CI failures in Boost.Regex. Could be related to boostorg/regex#49 and https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-3.8/+bug/1664321 |
Lastique
commented
Aug 20, 2018
I can only suggest adding |
apolukhin
commented
Aug 22, 2018
To speed up the fixes I sent emails directly to the Boost.Regex and Boost.Locale maintainers. |
apolukhin
commented
Aug 25, 2018
Seems that the issues were resolved in submodules. I'm in favour of merging this PR. |
apolukhin
commented
Aug 31, 2018
@Lastique could you please rebase the PR on top of the boostorg/boost to force the CI run on fixed submodules? |
This commit uses the new visibility feature added in boostorg/build@898ddfa and enables hidden visibility by default for Boost libraries.
glenfe
commented
Sep 10, 2018
Looks like there was sufficient consensus (or insufficient dissent). We observe the effect on the develop testers. |
I have test issues in boost.test example folder, which are not run by the current boost regression test (develop was green last week). Edit: I cannot reproduce the error locally (XCode9.3). The build machines are on OSX10.10 and build with clang6 using |
swatanabe
commented
Sep 12, 2018
via email
AMDG On 09/12/2018 03:01 PM, Raffi Enficiaud wrote:
I have test issues in boost.test example folder, which are not run by the current boost regression test (develop was green last week).
What should I do?
a) How is that related to this issue?
b) What kind of issues are we talking about?
c) Do you think that these examples should
be run by the regression tests?
In Christ,
Steven Watanabe |
raffienficiaud
commented
Sep 12, 2018
a) rev 638c880c5a5896bfabc13cedc7cf83d7b65a2ba5 (master) was green on boost.test side, and it turned red without any change for GCC5.4 and clang6. b) it is firing an test error with shared linked boost.test. The test is short: but the decorator is not taken into account. c) absolutely! Those are valid use case. I am running those on my own CI. Do you think we can integrate those to the boost CI? |
swatanabe
commented
Sep 12, 2018
via email
AMDG On 09/12/2018 03:32 PM, Raffi Enficiaud wrote:
a) rev 638c880c5a5896bfabc13cedc7cf83d7b65a2ba5 (master) was green on boost.test side, and it turned red without any change for GCC5.4 and clang6.
<snip> Since I am not able to reproduce from a more recent compiler, I also tend to think this is a compiler bug.
Well, I don't have either of those compiler versions
set up either, and I'm not really an expert on
visibility issues, so I'll leave this for someone else. c) absolutely! Those are valid use case. I am running those on my own CI. Do you think we can integrate those to the boost CI?
The test Jamfile should explicitly build the examples, then.
See https://www.boost.org/development/requirements.html#Integration
In Christ,
Steven Watanabe |
apolukhin
commented
Sep 13, 2018
My assumption is that compiler get nuts because of the I'll hopefully get to the PC in weekends to find out the fix for the issue |
Related to the changes in boostorg/boost#190
raffienficiaud
commented
Sep 13, 2018
@apolukhin I also think that the compiler removes the symbol erroneously. However, I am also wondering: this should be client code only? I mean, apart from that, boost.test seem to be working fine, means that the generated .so has all the necessary. What is your opinion on that? |
raffienficiaud
commented
Sep 16, 2018
@apolukhin Did you have the chance to look deeper into this? As a workaround, how can I remove this option from boost.test? |
Lastique
commented
Sep 16, 2018
@raffienficiaud You can add However, it might be better to mark the global variable with We should probably move the discussion to a Boost.Test ticket. |
raffienficiaud
commented
Sep 17, 2018
@Lastique thanks, I will check with the global or explicit visibility of those symbols, even if this seems to be a compiler bug. Concerning the move of this discussion to boost.test, I am not sure the issue will get the attention from your side if we do so. |
apolukhin
commented
Sep 17, 2018
+1 for trying out P.S.: It took unexpectedly long to fix the visibility related test failures in Stacktrace library. I've finished a few hours ago and I had no chance to look at the issue with Test. I'll try hard to find some time at this week. |
Lastique
commented
Sep 17, 2018
You can mention me in that ticket if you want to draw my attention. |
apolukhin
commented
Sep 17, 2018
@raffienficiaud I've reproduced the issue locally and now trying to find a fix |
raffienficiaud
commented
Sep 17, 2018
@apolukhin Thanks for looking into this! |
@raffienficiaud Perpending all the Most important functions are I'm not sure that my fix fits the Boost.Test development practice (and I do not fully understand the Boost.Test internals). Please take a look that it's the right thing to put |
raffienficiaud
commented
Sep 18, 2018
@apolukhin Thanks for digging this out! Do you have an explanation for this? The singleton itself has normally public visibility... I do not understand :) |
apolukhin
commented
Sep 18, 2018
I've made a PR for fixing some of the visibility issues: boostorg/test#166 BUT it does not work right now, but works if add -fvisibility=hidden works as expected when building shared objects. But does a strange thing for executables. It makes all the symbols hidden (probably because exporting symbols from the binary requires -rdynamic) So the full fix will require setting |
raffienficiaud
commented
Sep 18, 2018
@apolukhin I've seen it and my CI is testing right now, many thanks. Apart from the visibility (symbol not being visible), I do not understand why the side effects of this symbol are not handled. It looks like, the symbols being removed, all their possible effects are also removed. This looks like a huge compiler bug to me, so I tend to think that we are missing something... |
apolukhin
commented
Sep 19, 2018
The side effects are not removed. They are applied to another singleton, that is not used after applying the stuff. I've put a stacktrace printing and it showed two singletons, one in the executable, the other one in the shared library of Boost.Test. |
raffienficiaud
commented
Sep 19, 2018
That explains - almost - everything, indeed! many thanks! But this also opens a new question, and the fact that Visual does the job right and not GCC or Clang is troubling. The singleton is marked with import/export symbol (through Once I am inside any Any other decorator either refers directly to the singleton So the question remains open :-) |
From this https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Function-Attributes.html
Would protected would be better for a singleton? |
apolukhin
commented
Sep 21, 2018
Nope, still bad. You'll apply the problem with executables to the shared objects. Here's how it would probably work: you have a.so and b.so, both have singleton instances. With default visibility linker will map both entities into one address (will make one entity). With protected visibility c.so will see singleton from a.so or b.so, but a.so and b.so will have their own instances of singletons. a.so will work with its own singleton, b.so will work with its own singleton, c.so will work with some singleton (from a.so or b.so) With executables the problem is that default visibility stops working on executables biuld with hidden visibility and without -rdynamic like flags. For that case executable a.out has it's own singleton, a.so has it's own singleton. Linker does not unify those, so a.so uses it's own singleton, while a.out uses its own. You may also try to hide the singleton entirely in the .so so that in the the executable it is never instantiated |
apolukhin
commented
Sep 22, 2018
@raffienficiaud I've updated the PR boostorg/test#166 P.S.: have not test it on Windows |
raffienficiaud
commented
Sep 22, 2018
@apolukhin Yes, I also fixed it like this, many thanks! but here are my findings:
I started getting rid of the singleton implementation, as it does not what it is supposed to do properly. Thank you for the time you took for assisting me with this. I am still a bit worried as boost.test contains several singletons in different places. I will inspect with |
Visibility is different in that it is simply a markup that can be applied to any symbol that is put in the symbol table of the module. It does not alter its mangling or causes additional code generation but it does get reflected in the symbol table of the shared library. The symbol table contains both the symbols that are implemented by the module and the symbols it is missing, and the runtime linker will try to resolve the missing symbols as it loads shared libraries into the running process. When you mark a symbol visible (i.e. with default or global visibility), the compiler will still emit it in every library where it's defined. But at load time only a single copy will be used (from the first library that gets loaded in the process). From the language perspective, this has pretty much the same effect as Protected visibility is a rare beast, as it is not supported on all platforms. It works as the global (default) visibility, except that if the symbol is referenced from the same executable, the reference is always resolved to the copy in that executable. I'm not entirely sure how that works in cases when multiple shared objects in a process have the same symbol; most likely this is just a recipe for trouble, so just avoid it unless you know what you're doing. |
apolukhin
commented
Oct 20, 2018
@glenfe how about merging this commit to master? Looks like all the issues were resolved and we still have time to stabilize master if something goes wrong. |
raffienficiaud
commented
Oct 21, 2018
@apolukhin@glenfe Maybe an announce on the ML would also be good. |
This commit uses the new visibility feature added in boostorg/build@898ddfa and enables hidden visibility by default for Boost libraries.
The discussion that led to this PR is here:
http://boost.2283326.n4.nabble.com/all-Request-for-out-of-the-box-visibility-support-tt4704134.html