Skip to content

Commit

Permalink
Fix symbol visibility on Linux when compiling with -fvisibility=hidden
Browse files Browse the repository at this point in the history
Make FMT_API symbols use the default visibility on non-Windows
platforms. Otherwise, one cannot use the generated fmt library when
compiling globally with -fvisibility=hidden.

Fixes compile errors like:

```
../3rdParty/fmt/include/fmt/core.h:757: error: undefined reference to 'fmt::v6::internal::assert_fail(char const*, int, char const*)'
```

Note that the symbol exists, but is local:

```
$ nm -C libfmtd.so.6.1.3  | grep assert_fail
                 U __assert_fail
0000000000233ffa t fmt::v6::internal::assert_fail(char const*, int, char const*)
```

With this patch, the compile error is gone and the symbol is properly
exported:

```
$ nm -a bin/libfmtd.so -C | grep assert_fail
                 U __assert_fail
00000000002366ba T fmt::v6::internal::assert_fail(char const*, int, char const*)
```
  • Loading branch information
milianw committed Jan 27, 2020
1 parent 1acb73f commit dcd956f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@
# define FMT_CLASS_API
#endif
#ifndef FMT_API
# define FMT_API
# if defined(_WIN32)
# define FMT_API
# else
# define FMT_API __attribute__((visibility("default")))
# define FMT_EXTERN_TEMPLATE_API FMT_API
# endif
#endif
#ifndef FMT_EXTERN_TEMPLATE_API
# define FMT_EXTERN_TEMPLATE_API
Expand Down

0 comments on commit dcd956f

Please sign in to comment.