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

fails to build on arch linux #736

Open
wantija opened this issue Dec 14, 2022 · 4 comments
Open

fails to build on arch linux #736

wantija opened this issue Dec 14, 2022 · 4 comments

Comments

@wantija
Copy link

wantija commented Dec 14, 2022

title, laltest commit e4da2d4 fails to build on arch linux even in a clean chroot. gist the terminal log: https://gist.github.com/wantija/8a91a1fec19781d18dbf01922bc83c4b

@logological
Copy link

logological commented Jul 12, 2023

Same problem with GCC on openSUSE Tumbleweed. The problem seems to be that GCC (possibly unlike clang) is more fussy (or less intelligent) about reaching the end of a non-void function without a return statement, as occurs in cubeb_utils.cpp:

size_t cubeb_sample_size(cubeb_sample_format format)
{
  switch (format) {
    case CUBEB_SAMPLE_S16LE:
    case CUBEB_SAMPLE_S16BE:
      return sizeof(int16_t);
    case CUBEB_SAMPLE_FLOAT32LE:
    case CUBEB_SAMPLE_FLOAT32BE:
      return sizeof(float);
    default:
      // should never happen as all cases are handled above.
      assert(false);
  }
}

I believe that cubeb's default build may be set up to treat such return-type warnings as errors. The problem can be worked around by adding __builtin_unreachable(); after the switch statement; this is a non-standard compiler optimization hint that is recognized by GCC (and also Clang, I believe). An alternative solution would be to update the build files with something like Wno-error=return-type.

@padenot
Copy link
Collaborator

padenot commented Jul 12, 2023

This was fixed a while ago in https://github.com/mozilla/cubeb/pull/571/files#diff-c83414b24af193c5d964ce25a94a079c72000e2b868d56d219a676b2ff28f809. The problem in the original post is different, it's a linker issue in a test.

Let me know if it still happens, we mostly use clang these days so an issue with gcc is plausible.

@logological
Copy link

That fix is functionally equivalent to the workaround I propose, and has the advantage of being portable across compilers. I'm able to compile with it. Thanks!

@padenot
Copy link
Collaborator

padenot commented Jul 12, 2023

https://en.cppreference.com/w/cpp/utility/unreachable will be available in C++23, but Firefox (and therefore cubeb) is for now a C++17 project. It's not too hard with a little macro work to do a portable version, but what we have work for our purpose indeed.

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