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

Building cxxopts no longer works on Linux (Ubuntu 24.04) #2275

Open
7 tasks done
slam-bert opened this issue Jul 30, 2024 · 23 comments
Open
7 tasks done

Building cxxopts no longer works on Linux (Ubuntu 24.04) #2275

slam-bert opened this issue Jul 30, 2024 · 23 comments
Labels

Comments

@slam-bert
Copy link

Validation

Describe what's going wrong

When compiling the latest commit of Xenia on Linux as of this post (3d30b2e), building cxxopts fails with multiple of the same error.

I was able to resolve the errors by replacing
if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
with
if (u > static_cast<U>((std::numeric_limits<T>::min)()))
in cxxopts.hpp.
I got this fix from the latest cxxopts commit as of posting (2ad116a).

If possible, could this fix be somehow implemented?

Describe what should happen

cxxopts should compile just fine.

If applicable, provide a callstack here, especially for crashes

No response

If applicable, upload a logfile and link it here

Building debug...

- running premake...
Building configurations...
    Baking aes_128...
    Baking capstone...
    Baking dxbc...
    Baking discord-rpc...
    Baking cxxopts...
    Baking cpptoml...
    Baking libavcodec...
    Baking libavutil...
    Baking fmt...
    Baking glslang-spirv...
    Baking imgui...
    Baking mspack...
    Baking snappy...
    Baking xxhash...
    Baking xenia-core...
    Baking xenia-app...
    Baking xenia-app-discord...
    Baking xenia-apu...
    Baking xenia-apu-nop...
    Baking xenia-base...
    Baking xenia-base-tests...
    Baking xenia-cpu...
    Baking xenia-cpu-tests...
    Baking xenia-cpu-ppc-tests...
    Baking xenia-cpu-backend-x64...
    Baking xenia-debug-ui...
    Baking xenia-gpu...
    Baking xenia-gpu-shader-compiler...
    Baking xenia-gpu-null...
    Baking xenia-gpu-vulkan...
    Baking xenia-gpu-vulkan-trace-viewer...
    Baking xenia-gpu-vulkan-trace-dump...
    Baking xenia-hid...
    Baking xenia-hid-demo...
    Baking xenia-hid-nop...
    Baking xenia-kernel...
    Baking xenia-ui...
    Baking xenia-ui-vulkan...
    Baking xenia-ui-window-vulkan-demo...
    Baking xenia-vfs...
    Baking xenia-vfs-dump...
    Baking xenia-vfs-tests...
    Baking xenia-apu-sdl...
    Baking xenia-helper-sdl...
    Baking xenia-hid-sdl...
Running action 'gmake2'...
Done (1204ms).

- building (all):debug...
make: Entering directory '/home/brt/Downloads/xenia/build'
==== Building aes_128 (debug_linux) ====
==== Building capstone (debug_linux) ====
==== Building dxbc (debug_linux) ====
==== Building discord-rpc (debug_linux) ====
==== Building cxxopts (debug_linux) ====
==== Building cpptoml (debug_linux) ====
==== Building libavutil (debug_linux) ====
==== Building fmt (debug_linux) ====
==== Building glslang-spirv (debug_linux) ====
==== Building imgui (debug_linux) ====
==== Building xenia-base (debug_linux) ====
==== Building snappy (debug_linux) ====
==== Building xxhash (debug_linux) ====
==== Building xenia-app-discord (debug_linux) ====
==== Building xenia-helper-sdl (debug_linux) ====
clock.cc
clock_posix.cc
clock_x64.cc
cvar.cc
In file included from ../src/xenia/base/clock_x64.cc:10:
In file included from ../src/xenia/base/clock.h:16:
In file included from ../src/xenia/base/cvar.h:19:
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -2147483648 with type 'int' [-Werror,-Winteger-overflow]
In file included from ../src/xenia/base/clock_posix.cc:13:
  In file included from 488../src/xenia/base/clock.h | : 16 :
 In file included from  ../src/xenia/base/cvar.h : 19 :
  ../third_party/cxxopts/include/cxxopts.hpp : 488 if (u: 36>:  staerror: ticoverflow in expression; result is -2147483648 with type 'int' [-Werror,-Winteger-overflow]_c
ast<U>(-(std::n  u488m | e r i c _ l i m i t s < Ti>f: :(mui n>) (s)t)a)ti
c      _| ca                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~s
t<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -9223372036854775808 with type 'long' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -9223372036854775808 with type 'long' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/xenia/base/clock.cc:10:
In file included from ../src/xenia/base/clock.h:16:
In file included from ../src/xenia/base/cvar.h:19:
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -2147483648 with type 'int' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -9223372036854775808 with type 'long' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/xenia/base/cvar.cc:10:
In file included from ../src/xenia/base/cvar.h:19:
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -2147483648 with type 'int' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -9223372036854775808 with type 'long' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
2 errors generated.
make[1]: *** [xenia-base.make:249: obj/Linux/Debug/Linux/Debug/xenia-base/clock_posix.o] Error 1
make[1]: *** Waiting for unfinished jobs....
==== Building libavcodec (debug_linux) ====
make[1]: *** [xenia-base.make:252: obj/Linux/Debug/Linux/Debug/xenia-base/clock_x64.o] Error 1
2 errors generated.
make[1]: *** [xenia-base.make:246: obj/Linux/Debug/Linux/Debug/xenia-base/clock.o] Error 1
2 errors generated.
make[1]: *** [xenia-base.make:258: obj/Linux/Debug/Linux/Debug/xenia-base/cvar.o] Error 1
make: *** [Makefile:287: xenia-base] Error 2
make: Leaving directory '/home/brt/Downloads/xenia/build'

ERROR: build failed with one or more errors.
@slam-bert slam-bert added the bug label Jul 30, 2024
@Shoegzer
Copy link
Contributor

Shoegzer commented Aug 5, 2024

It's failing to build here too, on Linux Mint 22, which uses the Ubuntu 24.04 base. However, it fails earlier than cxxopts, with errors such as the following:

../../contrib/libzip/mkstemp.c: In function ‘_zip_mkstemp’:
../../contrib/libzip/mkstemp.c:76:15: error: implicit declaration of function ‘getpid’ [-Wimplicit-function-declaration]
   76 |         pid = getpid();
      |               ^~~~~~
lbitlib.c
make[2]: *** [zip-lib.make:303: obj/Release/zip-lib/mkstemp.o] Error 1
make[1]: *** [Makefile:74: zip-lib] Error 2
make[1]: *** Waiting for unfinished jobs....

This is related to gcc-14 pickiness, as explained here. I'm guessing you're using gcc-13 or below.

Here's my full build.log: xenia_build_log.txt

@nullequal
Copy link

It's failing to build here too, on Linux Mint 22, which uses the Ubuntu 24.04 base. However, it fails earlier than cxxopts, with errors such as the following:

../../contrib/libzip/mkstemp.c: In function ‘_zip_mkstemp’:
../../contrib/libzip/mkstemp.c:76:15: error: implicit declaration of function ‘getpid’ [-Wimplicit-function-declaration]
   76 |         pid = getpid();
      |               ^~~~~~
lbitlib.c
make[2]: *** [zip-lib.make:303: obj/Release/zip-lib/mkstemp.o] Error 1
make[1]: *** [Makefile:74: zip-lib] Error 2
make[1]: *** Waiting for unfinished jobs....

This is related to gcc-14 pickiness, as explained here. I'm guessing you're using gcc-13 or below.

Here's my full build.log: xenia_build_log.txt

easily fixable by adding #include <unistd.h> in mkstemp.c

@nullequal
Copy link

more implicit declarations with the zip_ files
fixable by adding #include <unistd.h> to all of them

@Shoegzer
Copy link
Contributor

Shoegzer commented Dec 7, 2024

Nice find. Can you make a PR with the additions?

@nullequal
Copy link

nullequal commented Dec 9, 2024

your issue is also fixable by updating the premake-core fork to the latest master
i believe fixing it this way is better. (i cant PR this however due to insufficient permissions)
please do test it yourself and notify me

@Shoegzer
Copy link
Contributor

Shoegzer commented Dec 9, 2024

Thanks. Attempted a git clone --recursive to update submodules including premake-core, but building still fails with the same results as above.

@nullequal
Copy link

nullequal commented Dec 9, 2024

can you try building premake-core from premake instead of using the xenia fork?
(clone the repo and run make -f Bootstrap.mak)

@Shoegzer
Copy link
Contributor

Thanks. After cloning the xenia repo, I substituted the xenia fork of premake-core with the upstream source in .gitmodules and then ran xb setup (which I believe executes make -f Boostrap.mak), however it still fails with the same results as above.

@nullequal
Copy link

you missed a step. you have to pull premake-core master and then commit
also, changing a submodule's URL in a local repo has some more steps other than just changing .gitmodules but I think git submodule set-url can do it.

(if you want to save yourself the hassle, you can use my fork's branch update-premake which i used to test this)

@Shoegzer
Copy link
Contributor

Ah yes, thanks for pointing that out. And actually, I just cloned your fork and did a git checkout update-premake but the xb setup threw the following error, do you know why? I assume it's looking for the original premake url.

Submodule path 'third_party/premake-cmake': checked out '91c646f638a6fbff20f0ea90769df8dcf62bc5e4'
fatal: remote error: upload-pack: not our ref 89971527dfe76690f52b74253478c1f037fe2c4b
fatal: Fetched in submodule path 'third_party/premake-core', but it did not contain 89971527dfe76690f52b74253478c1f037fe2c4b. Direct fetching of that commit failed.
Traceback (most recent call last):
  File "/home/testing/Desktop/xenia/./xb", line 1842, in <module>
    main()
  File "/home/testing/Desktop/xenia/./xb", line 179, in main
    return_code = command.execute(args, pass_args, os.getcwd())
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testing/Desktop/xenia/./xb", line 674, in execute
    git_submodule_update()
  File "/home/testing/Desktop/xenia/./xb", line 418, in git_submodule_update
    shell_call([
  File "/home/testing/Desktop/xenia/./xb", line 252, in shell_call
    subprocess.check_call(command, shell=shell, stdout=stdout_file, stderr=stderr_file)
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', '-c', 'fetch.recurseSubmodules=on-demand', 'submodule', 'update', '--init']' returned non-zero exit status 128.

@nullequal
Copy link

nullequal commented Dec 12, 2024

you can replace line 674 from xenia-build to preserve the commit (i messed up pulling the master so i recommend just not allowing the script to run git submodule update)

i will fix the fork soon enough do not worry

@Shoegzer
Copy link
Contributor

Thanks. Commenting out 674 wouldn't work because it's nested in an if/else, so I commented the statement (673-676). However since premake isn't built, it can't execute. What did you have in mind here if it wasn't this?

@nullequal
Copy link

nullequal commented Dec 12, 2024

maybe only replace line 674 with a statement like print('')

@Shoegzer
Copy link
Contributor

Thanks, but given that just having a print('') is the functional equivalent of commenting the entire if/else statement, I believe that still wouldn't work because premake isn't being built?

@nullequal
Copy link

weird its supposed to run fine, may I see the output?

@Shoegzer
Copy link
Contributor

Sure, from my attempt above I got:

$ ./xb setup
Setting up the build environment...

- git submodule init / update...

- running premake...
premake5 executable not found, attempting build...
make: Bootstrap.mak: No such file or directory
make: *** No rule to make target 'Bootstrap.mak'.  Stop.
ERROR: cannot build premake5 executable.

@nullequal
Copy link

nullequal commented Dec 13, 2024

i believe your clone has somehow bugged, as Bootstrap.mak for some reason does not exist when it should

@Shoegzer
Copy link
Contributor

Here is the full output of my attempt, which clones to a clean xenia directory. Note that after the xed xenia-build I edited the file to replace line 674 with print('') and nothing else.

testing:~/Desktop$ git clone https://github.com/nullequal/xenia
Cloning into 'xenia'...
remote: Enumerating objects: 73167, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 73167 (delta 0), reused 0 (delta 0), pack-reused 73166 (from 1)
Receiving objects: 100% (73167/73167), 44.52 MiB | 6.94 MiB/s, done.
Resolving deltas: 100% (54488/54488), done.
testing:~/Desktop$ cd xenia/
testing:~/Desktop/xenia$ git checkout update-premake
branch 'update-premake' set up to track 'origin/update-premake'.
Switched to a new branch 'update-premake'
testing:~/Desktop/xenia$ xed xenia-build 
testing:~/Desktop/xenia$ ./xb setup
Setting up the build environment...

- git submodule init / update...


- running premake...
premake5 executable not found, attempting build...
make: Bootstrap.mak: No such file or directory
make: *** No rule to make target 'Bootstrap.mak'.  Stop.
ERROR: cannot build premake5 executable.

Error!
testing:~/Desktop/xenia$ 

@nullequal
Copy link

nullequal commented Dec 13, 2024

you should do git clone --recursive -b update-premake https://github.com/nullequal/xenia.git instead since without --recursive you dont clone any submodules
(also i just got done fixing up my fork's branch, no need to edit xenia-build anymore)

@Shoegzer
Copy link
Contributor

Right thanks, I was doing that in the step before but in haste assumed it was still being done and missed it here.

The build is getting past the getpid error now, at least with your fork/branch, but then throws the cxxopts exception as described in the OP:

../third_party/cxxopts/include/cxxopts.hpp:488:36: error: overflow in expression; result is -2147483648 with type 'int' [-Werror,-Winteger-overflow]
  488 |             if (u > static_cast<U>(-(std::numeric_limits<T>::min)()))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This can be resolved by commenting out FatalWarnings in line 43 of premake5.lua, as @thrimbor suggests in PR #2277. However, it then runs into the issue that is apparently fixed by #2277 itself:

/usr/bin/ld: /tmp/lto-llvm-f82424.o: in function `main':
/home/testing/Desktop/xenia/build/../src/xenia/base/console_app_main_posix.cc:26:(.text.main+0xa4): undefined reference to `xe::InitializeLogging(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /home/testing/Desktop/xenia/build/../src/xenia/base/console_app_main_posix.cc:35:(.text.main+0x332): undefined reference to `xe::ShutdownLogging()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [xenia-vfs-tests.make:124: bin/Linux/Release/xenia-vfs-tests] Error 1
make: *** [Makefile:419: xenia-vfs-tests] Error 2

I'm sure there's a way to fetch PRs between forks to (hopefully) reach a successful build, but it may be best at this point to merge the known build fixes between yours and @thrimbor into upstream xenia. If there's a permissions issue then someone else on the xenia team can merge them. Thoughts?

@nullequal
Copy link

nullequal commented Dec 13, 2024

I was testing that idea just this morning and had a successful build.
fixing cxxopts is easy (no commenting FatalWarnings required): just pull the latest master, commit, and then fix errors.
then do as in PR #2277 and voila!

@nullequal
Copy link

nullequal commented Dec 14, 2024

see my forks (branch update-cxxopts) on how i do the second step
note that in this branch i use the cxxopts master which may be controversial (cxxopts master is unstable) so i recommend asking others first

@hd-genius
Copy link
Contributor

I just mad a PR to update the cxxopts version. @nullequal the latest master version was incompatible due to an API change in cxxopts so I set it to the latest tagged release of cxxopts v2 which resolved the issue. It's best to set the version to one of the tagged releases instead of directly to the latest master version because the master branch of cxxopts isn't necessarily stable. The tagged releases should be more stable as far as both bugs and build issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants