2013-11-19
| ||
09:11 | • Ticket [2959069fff] Support for -fvisibility=hidden status still Closed with 8 other changes artifact: b6c68976cd user: jan.nijtmans | |
09:09 | Revert [5215b8740c] (Enh [2959069]), as it turns out that -fvisibility=hidden only affects definitio... check-in: 8cce7b5a1a user: jan.nijtmans tags: trunk | |
2010-05-14
| ||
09:20 | • Closed ticket [2959069fff]: Support for -fvisibility=hidden plus 6 other changes artifact: 213a9ac62f user: sf-robot | |
2010-04-29
| ||
20:03 | • Pending ticket [2959069fff]. artifact: 69d7621f2d user: nijtmans | |
2010-03-03
| ||
20:17 | • Ticket [2959069fff]: 4 changes artifact: e0a54ad441 user: dkf | |
16:50 | • Ticket [2959069fff]: 4 changes artifact: 6b4edfec4a user: nijtmans | |
16:34 | • Ticket [2959069fff]: 4 changes artifact: 6f38b01a02 user: dkf | |
06:59 | • Ticket [2959069fff]: 1 change artifact: de0a7303fc user: nijtmans | |
06:58 | • Ticket [2959069fff]: 1 change artifact: 9de2d853ac user: nijtmans | |
06:58 | • Ticket [2959069fff]: 4 changes artifact: 175c079805 user: nijtmans | |
06:55 | • Ticket [2959069fff]: 4 changes artifact: 3a814edbc9 user: nijtmans | |
06:55 | • Add attachment visibility_hidden.patch to ticket [2959069fff] artifact: 8da3d587a5 user: nijtmans | |
06:54 | • Ticket [2959069fff] Support for -fvisibility=hidden status still Open with 4 other changes artifact: 18a509bb7b user: nijtmans | |
05:35 | • Ticket [2959069fff]: 4 changes artifact: d1875d9e02 user: nijtmans | |
05:29 | • Ticket [2959069fff]: 4 changes artifact: a10e1075b2 user: nijtmans | |
05:29 | • Ticket [2959069fff]: 4 changes artifact: 13eaffcbf1 user: nijtmans | |
2010-02-26
| ||
16:52 | • Ticket [2959069fff]: 4 changes artifact: b72eab9faf user: dkf | |
16:41 | • Ticket [2959069fff]: 5 changes artifact: 6cffe22790 user: nijtmans | |
16:37 | • Ticket [2959069fff]: 4 changes artifact: ebdea736f2 user: nijtmans | |
14:15 | • Ticket [2959069fff]: 4 changes artifact: b42dd7228e user: das | |
06:53 | • Ticket [2959069fff]: 4 changes artifact: 3498ac0b4b user: nijtmans | |
06:02 | • Ticket [2959069fff]: 5 changes artifact: 266f94ff7f user: das | |
05:44 | • Ticket [2959069fff]: 1 change artifact: 429a4beafc user: nijtmans | |
05:43 | • Ticket [2959069fff]: 4 changes artifact: cdea993894 user: nijtmans | |
2010-02-25
| ||
22:43 | • New ticket [2959069fff]. artifact: dd1911511d user: nijtmans | |
Ticket UUID: | 2959069 | |||
Title: | Support for -fvisibility=hidden | |||
Type: | Patch | Version: | None | |
Submitter: | nijtmans | Created on: | 2010-02-25 22:43:57 | |
Subsystem: | 52. Portability Support | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2013-11-19 09:11:01 | |
Resolution: | Fixed | Closed By: | jan.nijtmans | |
Closed on: | 2013-11-19 09:11:01 | |||
Description: |
Here is a patch, which makes the MODULE_SCOPE machinery unnecessary when using gcc. It makes everything compile with the gcc option -fvisibility=hidden (when available), so the EXPORT macro controls which symbols are exported. I am very interested to know whether Darwin, on which MODULE_SCOPE is currently translated by "__private_extern__" has a similar compiler options, making all symbols hidden by default, except the ones explicitely exported. Then MODULE_SCOPE can fully be deprecated. | |||
User Comments: |
jan.nijtmans added on 2013-11-19 09:11:01:
Reported by Stuart Cassoff: ================================= Hi! Here's some snippets from an obsd discussion on symbol visibility. I thought you might find it interesting. Stu ... 2) declares the internal functions explicitly hidden, instead of using -fvisibility=hidden and default declarations in sndio.h Why (2)? Well, -fvisibility=hidden doesn't actually get you the full performance benefits, as it only affects definitions and not declarations. The result is that inter-file file calls still use the PLT unless you explicitly declare the internal functions hidden. sf-robot added on 2010-05-14 09:20:18: allow_comments - 1 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). nijtmans added on 2010-04-29 20:03:37: Adding additional warning options seems out-of-scope for this Issue. If everything works fine, this simply should be closed. Agreed? dkf added on 2010-03-03 20:17:46: Maybe we should consider adding -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes (at least for gcc in debug mode; don't need to worry random builders, but do want to be able to audit for blunders) nijtmans added on 2010-03-03 16:50:39: Thanks, Donal. But it might be that, because of this change, some symbols that were exported before, are not exported any more. I found and fixed 2 such cases in Tk. Every such difference is a bug, unrelated to this change! I can see 2 possibilities for this to happen: - A missing #include, so the EXTERN in this include is not picked up by the compiler - symbols which neither have EXTERN nor MODULE_SCOPE. So, could anyone do a build (both Tcl and Tk) with the current "configure" script and the previous one, and compare the list of exported symbols. It should be exactly the same! dkf added on 2010-03-03 16:34:39: Seems to function correctly for me on OSX (as in "a clean configure and build with it works"). Great! nijtmans added on 2010-03-03 06:58:48: Patch was still not 100% correct, but now it is. DKF's and DAS's remark handled. Checked in for HEAD. Assigning to das, could you please check if everything works on mac as well? I am pretty sure it works as is, but checking never hurts. Thanks! nijtmans added on 2010-03-03 06:55:29: File Added - 365189: visibility_hidden.patch nijtmans added on 2010-03-03 06:54:27: File Deleted - 365183: nijtmans added on 2010-03-03 05:35:26: New version of patch, reverting to the current behavior if -fvisibility=hidden is not available. So, no regression. nijtmans added on 2010-03-03 05:29:51: File Added - 365183: visibility_hidden.patch nijtmans added on 2010-03-03 05:29:16: File Deleted - 364439: dkf added on 2010-02-26 16:52:28: Since we're going to be supporting all sorts of different compilers (on some platforms I use, I've got gcc 2.* still) for a long time across lots of platforms, I can't see that removing MODULE_SCOPE is necessarily a good move. The "get the overall visibility right" is an audit requirement, and we have make targets to support it. If you want to rewrite configure so as to allow for the case you describe (compiler flag, etc.) then that could be trialled. But that's a configure change and not a change to the Tcl and Tk sources. nijtmans added on 2010-02-26 16:41:00: This means, in fact, that the title of this Issue is wrong. The goal is not to phase out MODULE_SCOPE, the goal is to add support for compilers who, like gcc 4.x have a command line option to make all symbols hidden except especially decorated ones. nijtmans added on 2010-02-26 16:37:56: >All that said, I am strongly in favor of using -fvisibility=hidden when >available, I just think it would be a shame to loose the extra flexibility >the current scheme affords us w.r.t non-gcc compilers/linkers. Yes, I fully agree with that. My goal is first get gcc 4.x working with -fvisibility=hidden, and for all other compilers keep using the current MODULE_SCOPE method. Then later we can always extend it to let other compilers use their -fvisiliby=hidden variant. das added on 2010-02-26 14:15:44: as mentioned, IMO it would be better to have a configure check for __attribute__ ((visibility("default"))), gcc > 3 is not the only compiler that supports this, so the check in tcl.h will miss some cases and be a regression over the current state of things. as far as discovering mistakenly exported symbols, that's what the 'checkexports' and 'checkstubs' makefile targets are there for... I try to remember to run these shortly before a release to make sure that we didn't forget any decorations. All that said, I am strongly in favor of using -fvisibility=hidden when available, I just think it would be a shame to loose the extra flexibility the current scheme affords us w.r.t non-gcc compilers/linkers. nijtmans added on 2010-02-26 06:53:31: Thanks for the reaction! - The handling of __attribute__((__visibility__("default"))) is done in tcl.h, and this is already available. Also, the needed -DBUILD_tcl and -DBUILD_tk is already part of the current Makefile.in. It should work for Darwin as is.... > After all the work adding MODULE_SCOPE everywhere, where is the > need/benefit to removing it again? I wouldn't start removing it, until it's been well tested on all platforms. (I called it 'deprecate', not 'remove'). However, being obliged to decorate all exported symbols with EXTERN and all others with MODULE_SCOPE, that's asking for trouble forgetting one. Before starting with this, I compared the list of Tk exported symbols, and found two problematic symbols. One that didn't respect the EXTERN because of a missing include (TkpCmapStressed), another symbol that was not supposed to be exported at all (TkSetTransientFor). I fixed those two, but with -fvisibility=hidden, it would already have been discovered long ago.... Anyway, it's not high priority. I agree that the attribute should be kept as fallback. Any more remarks? das added on 2010-02-26 06:02:08: with recent enough gcc, we use visibility hidden on Darwin as well, but with older gcc that did not support visibility attributes yet we fall back to the Apple extension private_extern. MODULE_SCOPE affords us the flexibility to accommodate compiler/linkers that don't have an option to hide symbols by default and only export certain marked symbols. After all the work adding MODULE_SCOPE everywhere, where is the need/benefit to removing it again? Note that there are compilers (e.g. clang) that support __attribute__((__visibility__("hidden"))) but do not have the same commandline flags as gcc, your patch would be a regression there, the check for the attribute should remain as a fallback if the test for -fvisibility=hidden fails. Also, the current patch does not seem to test for __attribute__((__visibility__("default"))), which you will presumably need for the EXPORT macro ? (also not part of the patch) nijtmans added on 2010-02-26 05:43:57: File Added - 364439: visibility_hidden.patch |
Attachments:
- visibility_hidden.patch [download] added by nijtmans on 2010-03-03 06:55:29. [details]