dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
86 stars 21 forks source link

Build fails on Sonoma with clang-15: `error: use of undeclared identifier 'LC_COLLATE_MASK'` etc. #397

Open barracuda156 opened 11 months ago

barracuda156 commented 11 months ago
/opt/local/bin/clang++-mp-15 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -DHAVE_PNG_H -I/opt/local/include/libpng16 -I/opt/local/include/X11 -DDarwin -I/opt/X11/include -DHAVE_FREETYPE -Iext/ftgl -I/opt/local/include/freetype2 -I/opt/local/include/libpng16 -DR_NO_REMAP -Iext -Iext/glad/include  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk    -fPIC  -pipe -Os -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -arch arm64  -c rglview.cpp -o rglview.o
In file included from rglview.cpp:8:
In file included from /opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:203:
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:133:20: error: use of undeclared identifier 'LC_COLLATE_MASK'
        collate  = LC_COLLATE_MASK,
                   ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:134:20: error: use of undeclared identifier 'LC_CTYPE_MASK'
        ctype    = LC_CTYPE_MASK,
                   ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:135:20: error: use of undeclared identifier 'LC_MONETARY_MASK'
        monetary = LC_MONETARY_MASK,
                   ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:136:20: error: use of undeclared identifier 'LC_NUMERIC_MASK'
        numeric  = LC_NUMERIC_MASK,
                   ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:137:20: error: use of undeclared identifier 'LC_TIME_MASK'
        time     = LC_TIME_MASK,
                   ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:138:20: error: use of undeclared identifier 'LC_MESSAGES_MASK'
        messages = LC_MESSAGES_MASK,
                   ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:353:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:122:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:373:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:122:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:795:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:122:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:814:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:122:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:1048:5: error: unknown type name 'locale_t'; did you mean 'locale'?
    locale_t __l;
    ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__locale:122:24: note: 'locale' declared here
class _LIBCPP_TYPE_VIS locale
                       ^
In file included from rglview.cpp:8:
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:763:26: error: use of undeclared identifier 'strtoll_l'
        long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
                         ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:803:35: error: use of undeclared identifier 'strtoull_l'
        unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
                                  ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:832:12: error: use of undeclared identifier 'strtof_l'
    return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
           ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:838:12: error: use of undeclared identifier 'strtod_l'
    return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
           ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:844:12: error: use of undeclared identifier 'strtold_l'; did you mean 'strtoll'?
    return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
           ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/cstdlib:106:9: note: 'strtoll' declared here
using ::strtoll _LIBCPP_USING_IF_EXISTS;
        ^
In file included from rglview.cpp:8:
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:1118:9: error: use of undeclared identifier 'sscanf_l'
    if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
        ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/__bsd_locale_defaults.h:34:61: note: expanded from macro '__libcpp_sscanf_l'
#define __libcpp_sscanf_l(...)                              sscanf_l(__VA_ARGS__)
                                                            ^
In file included from rglview.cpp:8:
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:1225:18: error: use of undeclared identifier 'isxdigit_l'; did you mean 'isxdigit'?
            if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
                 ^
/opt/local/libexec/llvm-15/bin/../include/c++/v1/cctype:115:9: note: 'isxdigit' declared here
using ::isxdigit _LIBCPP_USING_IF_EXISTS;
        ^
In file included from rglview.cpp:8:
/opt/local/libexec/llvm-15/bin/../include/c++/v1/locale:1225:18: error: too many arguments to function call, expected 1, have 2; did you mean '::std::isxdigit'?
            if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
                 ^~~~~~~~~~
/opt/local/libexec/llvm-15/bin/../include/c++/v1/cctype:115:9: note: '::std::isxdigit' declared here
using ::isxdigit _LIBCPP_USING_IF_EXISTS;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [rglview.o] Error 1
dmurdoch commented 11 months ago

All of those errors are in files that are in /opt/local/libexec/llvm-15 and included by rgl, they aren't in rgl itself. So it's possible some define in rgl is conflicting with one in those files, but it looks to me that it's more likely a problem completely outside of rgl. If it's not something in your local configuration, it should be reported to the llvm-15 developers.

barracuda156 commented 11 months ago

@dmurdoch This is unlikely to be LLVM issue or our set-up issue, since rgl 1.2.1 does build on every OS apart from Sonoma on aarch64, it seems: https://ports.macports.org/port/R-rgl/details

dmurdoch commented 11 months ago

The evidence that it builds everywhere else suggests that it is an issue with LLVM or your setup. If it's an rgl issue, why does it only happen in that one particular configuration?

As I mentioned, it might be an rgl issue. I might be including things in an illegal way that other compilers tolerate, or I might be defining things that I shouldn't. But I don't have a Sonoma system to test on, so if you want this fixed, I think you're going to have to track it down.

I'd start by drastically simplifying the build. Delete as much of rgl as you can while still generating at least one of the errors you saw, and not introducing others. You should be able to get down to just one .cpp file and a small number of .h files. At that point maybe you'll spot an error in rgl and I'll fix it, or maybe you won't, and you'll have to look elsewhere.

barracuda156 commented 11 months ago

@dmurdoch Turns out this error happens only if X11 is enabled. Without X11 it builds fine.

As a dirty fix to unbreak the port, I will conditionally disable X11. But if you have an idea why specifically X11 introduces a locale-related breakage on Sonoma, please update me.

ryandesign commented 11 months ago

rgl 1.2.1 does build on every OS apart from Sonoma on aarch64, it seems: https://ports.macports.org/port/R-rgl/details

At present, that URL shows that rgl 1.2.1 builds successfully on every macOS version and architecture that the MacPorts automated build machines have attempted to build it on. It does not show a failure on Sonoma arm64; it shows that no builds have been attempted on Sonoma arm64, which is because I have not yet set up a Sonoma arm64 build machine for MacPorts.

barracuda156 commented 11 months ago

@ryandesign It fails to build locally on Sonoma aarch64. I know there is no buildbot atm.