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

Undefined `fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_32_new' on clang #2147

Closed
achaikou opened this issue Feb 24, 2021 · 9 comments

Comments

@achaikou
Copy link

Hi!

We build fmt from source and some of our builds started failing yesterday (same jobs suceeded 5 days ago).
We are not sure what's going on.

Undefined symbols for architecture x86_64:
  "fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_32_new",

(Travis, MacOS, AppleClang 9.1.0.9020039)
https://travis-ci.com/github/equinor/dlisio/jobs/485583924#L194

One other clang configuration fails in different place, but also during linking:

Linking CXX executable test-lis
/usr/bin/ld: libdlisio.so: undefined reference to 'fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_32_new'

(CircleCI, Debian, Clang 7.0.1)
(link might not be public) https://app.circleci.com/pipelines/github/equinor/dlisio/552/workflows/7a2a824d-c75a-42ea-ab93-d31b5e3ef11a/jobs/3422

Could you please take a look?
Thanks!

@vitaut
Copy link
Contributor

vitaut commented Feb 24, 2021

Interesting. The symbol in question is defined here:

constexpr uint32_t basic_data<T>::zero_or_powers_of_10_32_new[];

Does replacing constexpr with const fix the issue?

@achaikou
Copy link
Author

Assuming that we understood you correctly, attempted to run same with fmt master plus just this one line changed:

const uint32_t basic_data<T>::zero_or_powers_of_10_32_new[]; 

Travis gcc and clang jobs failed.
https://github.com/equinor/dlisio/runs/1971342182

gcc ones failed on building fmt:

[ 33%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.o
In file included from /home/travis/build/equinor/dlisio/fmt/src/format.cc:8:0:
/home/travis/build/equinor/dlisio/fmt/include/fmt/format-inl.h:261:59: error: ‘constexpr’ needed for in-class initialization of static data member ‘const uint32_t fmt::v7::detail::basic_data<T>::zero_or_powers_of_10_32_new [11]’ of non-integral type [-fpermissive]
 const uint32_t basic_data<T>::zero_or_powers_of_10_32_new[];

clang one failed again on linking with same issue as before.

CircleCI gcc jobs passed, clang once again failed on linking with same issue as before.

Looks like everything worked fine as before commit 2797588 changes.

@vitaut
Copy link
Contributor

vitaut commented Feb 25, 2021

Yeah, I figured that it's due to to 2797588. Unfortunately I wasn't repro the issue locally. I guess we should either revert the commit or (better) move this array to

FMT_CONSTEXPR20 inline int count_digits(uint32_t n) {
where it is used.

vitaut added a commit that referenced this issue Feb 25, 2021
@vitaut
Copy link
Contributor

vitaut commented Feb 25, 2021

Reverted 2797588 for now. Thanks for reporting.

@vitaut vitaut closed this as completed Feb 25, 2021
sthagen added a commit to sthagen/fmtlib-fmt that referenced this issue Feb 25, 2021
Revert "Optimize handling of integer constants" (fmtlib#2147)
@ErlendHaa
Copy link

ErlendHaa commented Apr 26, 2021

Hi!

This issue seams to have re-surfaced. I haven't pin-pointed the exact commit, but seems to be introduced again around 23.04. I'm having this issue on Clang 7.0.1 and AppleClang 9.1.0.9020039.

/usr/bin/ld: libdlisio.so: undefined reference to `fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_32'
/usr/bin/ld: libdlisio.so: undefined reference to `fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_64'

However, I have no issues on Apple Clang 12.0.0

@vitaut
Copy link
Contributor

vitaut commented Apr 26, 2021

These symbols were removed intentionally in preparation for the next major release.

@ErlendHaa
Copy link

ErlendHaa commented Apr 27, 2021

I see! Just to be clear tho, I do not reference these symbols myself. Here is a minimal working example:

mwe.cpp

#include <fmt/core.h>

int main() {
  fmt::print("Hello, world!\n");
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.5)
project(mwe LANGUAGES CXX)

find_package(fmt)

add_executable(mwe mwe.cpp)
target_link_libraries(mwe PRIVATE fmt::fmt-header-only)
$ cmake . && make
-- The CXX compiler identification is Clang 7.0.1
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /root/project/build
Scanning dependencies of target mwe
[ 50%] Building CXX object CMakeFiles/mwe.dir/mwe.cpp.o
[100%] Linking CXX executable mwe
/usr/bin/ld: CMakeFiles/mwe.dir/mwe.cpp.o: in function `fmt::v7::detail::count_digits(unsigned int)':
mwe.cpp:(.text._ZN3fmt2v76detail12count_digitsEj[_ZN3fmt2v76detail12count_digitsEj]+0x39): undefined reference to `fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_32'
/usr/bin/ld: CMakeFiles/mwe.dir/mwe.cpp.o: in function `fmt::v7::detail::count_digits(unsigned long)':
mwe.cpp:(.text._ZN3fmt2v76detail12count_digitsEm[_ZN3fmt2v76detail12count_digitsEm]+0x42): undefined reference to `fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_64'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/mwe.dir/build.make:84: mwe] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/mwe.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Not an issue when linking to fmt::fmt.

Anyway, just wanted to let you know. It's not issue for me atm, so feel free to ignore

@vitaut
Copy link
Contributor

vitaut commented Apr 27, 2021

Ah, you are referring to zero_or_powers_of_10_32, not zero_or_powers_of_10_32_new. Please create a new issue in cases like this.

@vitaut
Copy link
Contributor

vitaut commented Apr 28, 2021

Anyway, this is a clang <= 8 bug worked around in 84a36b9.

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

No branches or pull requests

3 participants