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

Build fails with clang on GLM_DEPRECATED GLM_FUNC_DECL construct #1269

Closed
AMDmi3 opened this issue Mar 1, 2024 · 4 comments · Fixed by #1286
Closed

Build fails with clang on GLM_DEPRECATED GLM_FUNC_DECL construct #1269

AMDmi3 opened this issue Mar 1, 2024 · 4 comments · Fixed by #1286

Comments

@AMDmi3
Copy link

AMDmi3 commented Mar 1, 2024

I've ran into this when build-testing one of glm consumers, gamescope, before updating FreeBSD port of glm to 1.x.

c++ -Isrc/gamescope_color_tests.p -Isrc -I../src -I/usr/local/include -fdiagnostics-color=never -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=c++20 -DWLR_USE_UNSTABLE -Wno-unused-parameter -Wno-missing-f
ield-initializers -Wno-c99-designator -Wno-invalid-offsetof -Wno-unused-const-variable -Wno-deprecated-volatile -Wno-ignored-qualifiers -Wno-missing-braces -ffast-math -DHAVE_PIPEWIRE=1 -DHAVE_OPENVR=0 '-DHWDATA_P
NP_IDS="https://usr/local/share/hwdata/hwdata/pnp.ids"' -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DGLM_ENABLE_EXPERIMENTAL -MD -MQ src/gamescope_color_tests.p/color_tests.cpp.o -MF src/gamescope_color_tes
ts.p/color_tests.cpp.o.d -o src/gamescope_color_tests.p/color_tests.cpp.o -c ../src/color_tests.cpp
In file included from ../src/color_tests.cpp:4:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:49:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoAbove(genIUType Value);
                       ^
/usr/local/include/glm/./ext/../detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/./ext/../detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^

Reproducible with

#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/bit.hpp>

What preprocessed line looks like:

__attribute__((__deprecated__)) [[nodiscard]] genIUType powerOfTwoAbove(genIUType Value);

Smaller repro (note that template is required):

template<class T> __attribute__((__deprecated__)) [[nodiscard]] int foo(T t);
% clang++-14 -std=c++20  -c 1.cc 
1.cc:1:51: error: an attribute list cannot appear here
template<class T> __attribute__((__deprecated__)) [[nodiscard]] int foo(T t);
                                                  ^~~~~~~~~~~~~
1 error generated.

I haven't dug into the docs, but simple experiment revealed two ways to fix it: either change the order of attributes or use attributes of the same format, e.g. change __attribute__((__deprecated__)) to [[deprecated]. Both compile by gcc and clang, and I suggest to use [[deprecated]] in glm, as it's standard and supported since c++14.

@pemsley
Copy link

pemsley commented Mar 3, 2024

My builds are failing too, I think it's because Homebrew has moved to version 1.0.1

https://github.com/pemsley/coot/actions/workflows/build-coot-macos.yml

In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.h:15:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:49:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoAbove(genIUType Value);
                       ^
/usr/local/include/glm/detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.cpp:10:
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.h:15:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:57:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL vec<L, T, Q> powerOfTwoAbove(vec<L, T, Q> const& value);
                       ^
/usr/local/include/glm/detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.cpp:10:
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.h:15:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:65:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoBelow(genIUType Value);
                       ^
/usr/local/include/glm/detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.cpp:10:
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.h:15:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:73:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL vec<L, T, Q> powerOfTwoBelow(vec<L, T, Q> const& value);
                       ^
/usr/local/include/glm/detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.cpp:10:
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.h:15:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:81:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL genIUType powerOfTwoNearest(genIUType Value);
                       ^
/usr/local/include/glm/detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.cpp:10:
In file included from ../../../coot/MoleculesToTriangles/CXXClasses/RepresentationInstance.h:15:
In file included from /usr/local/include/glm/ext.hpp:198:
/usr/local/include/glm/./gtx/bit.hpp:89:17: error: 'nodiscard' attribute cannot be applied to types
        GLM_DEPRECATED GLM_FUNC_DECL vec<L, T, Q> powerOfTwoNearest(vec<L, T, Q> const& value);
                       ^
/usr/local/include/glm/detail/setup.hpp:498:23: note: expanded from macro 'GLM_FUNC_DECL'
#define GLM_FUNC_DECL GLM_NODISCARD GLM_CUDA_FUNC_DECL
                      ^
/usr/local/include/glm/detail/setup.hpp:344:26: note: expanded from macro 'GLM_NODISCARD'
#       define GLM_NODISCARD [[nodiscard]]
                               ^
6 errors generated.
make[2]: *** [libMoleculesToTrianglesCXXClasses_la-RepresentationInstance.lo] Error 1

@tobbi
Copy link

tobbi commented Apr 7, 2024

#1252 was where [[nodiscard]] was added. @christophe-lunarg Can you take a look at this please?

@tobbi
Copy link

tobbi commented Apr 8, 2024

I hope the above PR fixes this.

@tobbi
Copy link

tobbi commented Apr 12, 2024

@christophe-lunarg When are you gonna release a new version of GLM? The SuperTux project relies on GLM for some maths and we're currently using an earlier version in the nightly builds and would like to use a current upstream version.

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 a pull request may close this issue.

3 participants