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

#1605 fmt custom namespace #1618

Merged
merged 6 commits into from
Dec 22, 2021
Merged

#1605 fmt custom namespace #1618

merged 6 commits into from
Dec 22, 2021

Conversation

jstrzebonski
Copy link
Contributor

@jstrzebonski jstrzebonski commented Dec 10, 2021

Fixes #1605


fmt has macros FMT_BEGIN_NAMESPACE and FMT_END_NAMESPACE, but unfortunately, internally it explicitly uses full namespace (in core.h):

namespace detail {
void to_string_view(...);
using fmt::v7::to_string_view;
...

To use it, we would have to hardcode our namespace anyway.

To solve this I extracted this "inner" namespace into an additional macro, so it could be simply defined in cmake.


I opened an issue in fmt repo regarding this problem
fmtlib/fmt#2642


Everything above is no longer valid. fmt team remove qualifying by inline namespace from core.h.

I copied their fix into our fmt/core.h and define FMT_BEGIN_NAMESPACE and FMT_END_NAMESPACE.

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (clang-3.9, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (clang-5.0, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (gcc-5, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (gcc-6, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (gcc-9, ubuntu, mpich, zoltan)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (gcc-7, ubuntu, mpich, trace runtime, LB)

Build for 8c07571

FAILED: tests/message_basic 
: && /usr/bin/g++ -O3 -DNDEBUG --coverage -rdynamic -Wl,-rpath -Wl,/usr/local/lib -Wl,--enable-new-dtags tests/CMakeFiles/message_basic.dir/Unity/unity_0_cxx.cxx.o -o tests/message_basic  -Wl,-rpath,/usr/local/lib  lib/brotli/libbrotlicommon-static.a  lib/brotli/libbrotlienc-static.a  lib/brotli/libbrotlidec-static.a  lib/libfort/lib/libfort.a  lib/libgtest.a  src/libvt-release.a  -ldl  /usr/lib/x86_64-linux-gnu/libz.so  lib/fmt/libfmt.a  /build/checkpoint/install/lib/libcheckpoint.a  -lpthread  lib/brotli/libbrotlienc-static.a  lib/brotli/libbrotlidec-static.a  lib/brotli/libbrotlicommon-static.a  -lm  lib/libfort/lib/libfort.a  /usr/local/lib/libmpicxx.so  /usr/local/lib/libmpi.so && :
collect2: error: ld returned 1 exit status
FAILED: tests/pipe_basic 
: && /usr/bin/g++ -O3 -DNDEBUG --coverage -rdynamic -Wl,-rpath -Wl,/usr/local/lib -Wl,--enable-new-dtags tests/CMakeFiles/pipe_basic.dir/Unity/unity_0_cxx.cxx.o -o tests/pipe_basic  -Wl,-rpath,/usr/local/lib  lib/brotli/libbrotlicommon-static.a  lib/brotli/libbrotlienc-static.a  lib/brotli/libbrotlidec-static.a  lib/libfort/lib/libfort.a  lib/libgtest.a  src/libvt-release.a  -ldl  /usr/lib/x86_64-linux-gnu/libz.so  lib/fmt/libfmt.a  /build/checkpoint/install/lib/libcheckpoint.a  -lpthread  lib/brotli/libbrotlienc-static.a  lib/brotli/libbrotlidec-static.a  lib/brotli/libbrotlicommon-static.a  -lm  lib/libfort/lib/libfort.a  /usr/local/lib/libmpicxx.so  /usr/local/lib/libmpi.so && :
collect2: error: ld returned 1 exit status
FAILED: tests/CMakeFiles/collection_extended.dir/Unity/unity_0_cxx.cxx.o 
/usr/bin/ccache /usr/bin/g++ -DFMT_BEGIN_NAMESPACE="namespace fmt { inline namespace vt {" -DFMT_END_NAMESPACE=}} -DJSON_USE_IMPLICIT_CONVERSIONS=1 -DVT_NO_COLOR_ENABLED -I/vt/tests/unit -I/vt/lib/CLI -I/vt/lib/json/include -I/vt/lib/brotli/c/include -I/vt/lib/libfort/lib -Irelease -I/vt/src -isystem /vt/tests/extern/googletest/googletest/include -isystem /vt/tests/extern/googletest/googletest -isystem /vt/lib/fmt/include -isystem /build/checkpoint/install/include -isystem /build/detector/install/include -O3 -DNDEBUG -fdiagnostics-color=always -Wall -pedantic -Wshadow -Wno-unknown-pragmas -Wsign-compare -ftemplate-backtrace-limit=100 -Werror -O0 -g --coverage -fPIC -std=c++14 -MD -MT tests/CMakeFiles/collection_extended.dir/Unity/unity_0_cxx.cxx.o -MF tests/CMakeFiles/collection_extended.dir/Unity/unity_0_cxx.cxx.o.d -o tests/CMakeFiles/collection_extended.dir/Unity/unity_0_cxx.cxx.o -c tests/CMakeFiles/collection_extended.dir/Unity/unity_0_cxx.cxx


Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (gcc-10, ubuntu, openmpi, no LB)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (nvidia cuda 11.0, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (clang-9, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (nvidia cuda 10.1, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (clang-10, alpine, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (clang-10, ubuntu, mpich)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@github-actions
Copy link

github-actions bot commented Dec 10, 2021

PR tests (gcc-8, ubuntu, mpich, address sanitizer)

Build for 9cb5849

Compilation - successful

Testing - passed

Build log

@jstrzebonski
Copy link
Contributor Author

There are some nvcc errors to be fixed.

@jstrzebonski
Copy link
Contributor Author

It seems that nvcc is unable to handle definitions with spaces. I also observed that definition defined within vt's cmake was "leaked" into my test app, where I wanted to use different fmt.

Currently I just hardcoded vt namespace in fmt code. It's just two places in core.h that needed modification, and it fixes both problems.

Copy link
Contributor

@cz4rs cz4rs left a comment

Choose a reason for hiding this comment

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

Currently I just hardcoded vt namespace in fmt code. It's just two places in core.h that needed modification, and it fixes both problems.

Looks good to me, imho that's acceptable "manual" maintenance burden.

@jstrzebonski
Copy link
Contributor Author

jstrzebonski commented Dec 14, 2021

Currently I just hardcoded vt namespace in fmt code. It's just two places in core.h that needed modification, and it fixes both problems.

Looks good to me, imho that's acceptable "manual" maintenance burden.

Yes, in case of fmt update, that's literally two characters that need to be changed.

@jstrzebonski jstrzebonski force-pushed the 1605-fmt-custom-namespace branch 3 times, most recently from 1ceb50d to 9da07ed Compare December 15, 2021 16:30
@jstrzebonski jstrzebonski force-pushed the 1605-fmt-custom-namespace branch 2 times, most recently from 9a9dd4d to ecd86ac Compare December 21, 2021 18:04
@lifflander lifflander force-pushed the 1605-fmt-custom-namespace branch from ecd86ac to 3dbe5af Compare December 21, 2021 21:51
@lifflander lifflander merged commit a5e6009 into develop Dec 22, 2021
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.

Potential ODR violations with fmt
3 participants