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

Failed to build with c++23 #656

Closed
iamfobey opened this issue Dec 8, 2022 · 11 comments
Closed

Failed to build with c++23 #656

iamfobey opened this issue Dec 8, 2022 · 11 comments

Comments

@iamfobey
Copy link

iamfobey commented Dec 8, 2022

Hello!

I'm always get error: non-const lvalue reference to type 'cppspmd_sse41::spmd_kernel::vfloat' cannot bind to a temporary of type 'cppspmd_sse41::spmd_kernel::vfloat when I'm trying to build KTX.

In file included from /media/dezlow/Drive/Dev/C++/Oneiro/ThirdParty/KTX/lib/basisu/encoder/basisu_kernels_sse.cpp:41:
/media/dezlow/Drive/Dev/C++/Oneiro/ThirdParty/KTX/lib/basisu/encoder/cppspmd_sse.h:496:10: error: non-const lvalue reference to type 'cppspmd_sse41::spmd_kernel::vfloat' cannot bind to a temporary of type 'cppspmd_sse41::spmd_kernel::vfloat'
                return dst;
                       ^~~
/media/dezlow/Drive/Dev/C++/Oneiro/ThirdParty/KTX/lib/basisu/encoder/cppspmd_sse.h:508:10: error: non-const lvalue reference to type 'cppspmd_sse41::spmd_kernel::vfloat' cannot bind to a temporary of type 'cppspmd_sse41::spmd_kernel::vfloat'
                return dst;
                       ^~~

I'm building my project with using GitHub Actions and I get the same error.

Sorry for my English, lol.

Thanks!

cat /etc/os-release

PRETTY_NAME="Debian GNU/Linux bookworm/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

clang --version

Debian clang version 14.0.6-2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
@MarkCallow
Copy link
Collaborator

MarkCallow commented Dec 8, 2022

Our CI builds with clang for macOS, Windows ARM and Emscripten. In addition macOS/Xcode 14 (clang 14.0.29) is my primary development environment. CI also builds on Ubuntu with GCC. Also I know a user who is successfully building with mingw_llvm. The issue is something specific to your situation and therefore not easy for me to debug.

The error appears to be related to the use of && on the dst parameter declaration but why only you are seeing it I have no idea. Please try to debug further yourself.

@MarkCallow MarkCallow changed the title Failed to build with using clang (and maybe with other compilers) in Linux Failed to build on Debian with clang Dec 8, 2022
@MarkCallow
Copy link
Collaborator

Changed title because KTX builds fine on Linux with GCC.

@iamfobey
Copy link
Author

iamfobey commented Dec 9, 2022

Our CI builds with clang for macOS, Windows ARM and Emscripten. In addition macOS/Xcode 14 (clang 14.0.29) is my primary development environment. CI also builds on Ubuntu with GCC. Also I know a user who is successfully building with mingw_llvm. The issue is something specific to your situation and therefore not easy for me to debug.
In my solution, I fix this with the following:

return  static_cast<vfloat&>(dst)

And it works fine, but I think it is a bad idea to fix this.

I tried to run PVS studio workflow in my project, but project not compiles and return the same error.
https://github.com/OneiroGames/Oneiro/actions/runs/3643926582/jobs/6152631619#step:4:2190

And video (maybe to be helpful)

simplescreenrecorder-2022-12-09_19.13.35.mp4

@MarkCallow
Copy link
Collaborator

Is this still an issue for you in main?

@Flone-dnb
Copy link

I just got the same error on Archlinux with Clang 16.

@MarkCallow
Copy link
Collaborator

I just got the same error on Archlinux with Clang 16.

On which branch? Which errors?

The latest code compiles via ClangCL both 15 & 16 in VS 2022. It compiles with clang 14 on macOS and clang 17 in Emscripten. I do not have the bandwidth to work on another platform. If you want this fixed I'll need a PR that fixes it. If the errors are in the lib/basisu/* code then the preferred fix is to disable the subject warnings in CMakeLists.txt. If elsewhere in lib then please fix the warnings.

@Flone-dnb
Copy link

Flone-dnb commented Sep 16, 2023

On which branch? Which errors?

Latest commit from main branch. Same errors as described above.

Changing 2 places in cppspmd_sse.h to:

return static_cast<vfloat&>(dst)

Fixes build.

P.S. With this fix, reading KTX files via libktx seems to work fine, can't tell about other things tho.

@MarkCallow
Copy link
Collaborator

I can't debug this or test fixes as my machine is arm64-based so SSE code is never compiled. I made a simple reproducer which I'm compiling with AppleClang 15.0.0. The error appears when compiling with --std=c++2b (i.e. draft c++23).

@Flone-dnb and @DezlowNG are you building with KTX-Software's CMakeLists.txt? Do you have a parent project that is including it? I'm guessing you must somehow be specifying C++23. Looks like I'll need to explicitly specify the c++ standard when compiling the library. First I'll see if I can find a code fix.

@MarkCallow MarkCallow changed the title Failed to build on Debian with clang Failed to build c++23 Nov 28, 2023
@MarkCallow MarkCallow changed the title Failed to build c++23 Failed to build with c++23 Nov 28, 2023
@MarkCallow
Copy link
Collaborator

I opened an issue upstream: BinomialLLC/basis_universal#366.

MarkCallow added a commit that referenced this issue Nov 28, 2023
MarkCallow added a commit that referenced this issue Nov 29, 2023
Avoid inadvertent compilation with a later standard
when included in another project. Later standards may
raise warnings or even errors on the library code. 

Fixes #774 and #656.
@MarkCallow
Copy link
Collaborator

Fixed by PR #806.

Flone-dnb added a commit to Flone-dnb/nameless-engine that referenced this issue Dec 4, 2023
@Flone-dnb
Copy link

@MarkCallow

are you building with KTX-Software's CMakeLists.txt? Do you have a parent project that is including it? I'm guessing you must somehow be specifying C++23

That's right.

I just tried using the latest commit (f8220ec) and I can confirm that everything builds correctly on Linux now.

Thanks.

KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
Avoid inadvertent compilation with a later standard
when included in another project. Later standards may
raise warnings or even errors on the library code. 

Fixes KhronosGroup#774 and KhronosGroup#656.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
Avoid inadvertent compilation with a later standard
when included in another project. Later standards may
raise warnings or even errors on the library code. 

Fixes KhronosGroup#774 and KhronosGroup#656.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
Avoid inadvertent compilation with a later standard
when included in another project. Later standards may
raise warnings or even errors on the library code. 

Fixes KhronosGroup#774 and KhronosGroup#656.
KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 22, 2024
Avoid inadvertent compilation with a later standard
when included in another project. Later standards may
raise warnings or even errors on the library code. 

Fixes KhronosGroup#774 and KhronosGroup#656.
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