Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix symbol leak #3627

Merged
merged 1 commit into from
Sep 16, 2023
Merged

Fix symbol leak #3627

merged 1 commit into from
Sep 16, 2023

Conversation

phprus
Copy link
Contributor

@phprus phprus commented Sep 8, 2023

Fix for issue #3626

@feltech, please test this PR.

Signed-off-by: Vladislav Shchapov <[email protected]>
@feltech
Copy link

feltech commented Sep 8, 2023

Fix looks good to me. I can confirm that, at least for our specific case of GCC 9 and CMake target fmt::fmt-header-only:

Current main leaks symbols:

$ nm --demangle --dynamic --defined-only --extern-only libopenassetio.so | grep fmt
00000000000b55f0 D typeinfo for fmt::v10::format_error
000000000007e410 R typeinfo name for fmt::v10::format_error
$

and this PR does not ;)

$ nm --demangle --dynamic --defined-only --extern-only libopenassetio.so | grep fmt
$

I'm still personally curious why this special case for format_error exists (not that its wrong, I just genuinely want to understand), but I'll follow-up in the issue.

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Comment on lines +102 to +107
#if !defined(FMT_HEADER_ONLY) && !defined(_WIN32) && \
(defined(FMT_LIB_EXPORT) || defined(FMT_SHARED))
# define FMT_INLINE_API FMT_VISIBILITY("default")
#else
# define FMT_INLINE_API
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should introduce a new macro. Let's update FMT_VISIBILITY instead since we shouldn't be changing visibility in general when not compiling a shared library.

Copy link
Contributor Author

@phprus phprus Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitaut
FMT_VISIBILITY is used unconditionally:

fmt/include/fmt/format.h

Lines 1883 to 1885 in a4b7b24

/* Use the hidden visibility as a workaround for a GCC bug (#1973). */ \
/* Use a macro-like name to avoid shadowing warnings. */ \
struct FMT_VISIBILITY("hidden") FMT_COMPILE_STRING : base { \

Therefore, we need two macros.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we can simplify this later.

@phprus phprus requested a review from vitaut September 11, 2023 17:40
@vitaut vitaut merged commit 016b1fa into fmtlib:master Sep 16, 2023
@vitaut
Copy link
Contributor

vitaut commented Sep 16, 2023

Merged, thanks!

ckerr pushed a commit to transmission/fmt that referenced this pull request Nov 7, 2023
Signed-off-by: Vladislav Shchapov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants