Skip to content

[REACTOS] Add support for compiling with GCC 13#6824

Merged
tkreuzer merged 3 commits intoreactos:masterfrom
tkreuzer:RosBE/GCC13-build
Jul 9, 2024
Merged

[REACTOS] Add support for compiling with GCC 13#6824
tkreuzer merged 3 commits intoreactos:masterfrom
tkreuzer:RosBE/GCC13-build

Conversation

@tkreuzer
Copy link
Copy Markdown
Contributor

@tkreuzer tkreuzer commented May 1, 2024

Purpose

This PR makes it possible to compile ros with GCC 13. It will still create warnings, so for x86 it requires to remove -Werror

Proposed changes

  • Add some compiler flags for GCC 13
  • Add imported library winpthread
  • Add support library for GCC's libsupc++ and libstdc++

@tkreuzer tkreuzer self-assigned this May 1, 2024
@tkreuzer tkreuzer added the GCC-13 Fixes to get ROS build with GCC 13 label May 1, 2024
@tkreuzer tkreuzer force-pushed the RosBE/GCC13-build branch from 561b950 to 1e0829c Compare May 1, 2024 09:20
set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${LIBGCC_LOCATION})
# libgcc needs kernel32 imports, a CRT and msvcrtex
target_link_libraries(libgcc INTERFACE libkernel32 libmsvcrt msvcrtex)
target_link_libraries(libgcc INTERFACE libwinpthread libkernel32 libmsvcrt msvcrtex)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geez GCC... why the hell do they need winpthread?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For threading support in their runtime library I guess. The better alternative on Windows would be MCF Gthread, but that requires Windows 7.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do hope all this gcc nastiness is static, and our binaries do not actually depend on some shit like winpthread.dll or so?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was wondering too.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Luckily, libwinpthread and libgcc_dw2 / libgcc_seh2 can be statically linked to the produced executable (it's actually a compiler option of the configure step of gcc buildscript that ends up generating libwinpthread.dll.a or libwinpthread.a).

@HBelusca HBelusca self-requested a review May 1, 2024 09:39
@binarymaster binarymaster added the enhancement For PRs with an enhancement/new feature. label May 1, 2024
Copy link
Copy Markdown
Contributor

@HBelusca HBelusca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK but Timo please fix that Copyright 202024 date in the three new files.

Comment on lines +59 to +68
add_compile_options(-fno-builtin-sin)
add_compile_options(-fno-builtin-cos)
add_compile_options(-fno-builtin-sincos)
add_compile_options(-fno-builtin-pow)
add_compile_options(-fno-builtin-sqrt)
add_compile_options(-fno-builtin-sqrtf)
add_compile_options(-fno-builtin-floor)
add_compile_options(-fno-builtin-floorf)
add_compile_options(-fno-builtin-ceilf)
add_compile_options(-fno-builtin-ceil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort them. Want to merge them into "1" line?

Copy link
Copy Markdown
Contributor

@cbialorucki cbialorucki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fix the copyright dates

@wjk
Copy link
Copy Markdown
Contributor

wjk commented May 18, 2024

If I understand correctly, this new library is required for any code compiled with GCC to run. winpthread dependency aside, does this not mean that everything now depends on kernel32.dll and msvcrt.dll, including kernel components and DLLs lower than kernel32 and msvcrt? Won’t this cause problems?

set_target_properties(libsupc++ PROPERTIES IMPORTED_LOCATION ${LIBSUPCXX_LOCATION})
# libsupc++ requires libgcc
target_link_libraries(libsupc++ INTERFACE libgcc)
target_link_libraries(libsupc++ INTERFACE libgcc stdc++compat)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment too?

Comment on lines 571 to +572
# libgcc needs kernel32 imports, a CRT and msvcrtex
target_link_libraries(libgcc INTERFACE libkernel32 libmsvcrt msvcrtex)
target_link_libraries(libgcc INTERFACE libwinpthread libkernel32 libmsvcrt msvcrtex)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment too?

@HBelusca
Copy link
Copy Markdown
Contributor

I wonder whether it is possible to add a temporary github action that makes use of GCC13, to see how things go.

Copy link
Copy Markdown
Contributor

@oleg-dubinskiy oleg-dubinskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nit-picks, LGTM otherwise.

execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libsupc++.a OUTPUT_VARIABLE LIBSUPCXX_LOCATION)
string(STRIP ${LIBSUPCXX_LOCATION} LIBSUPCXX_LOCATION)
set_target_properties(libsupc++ PROPERTIES IMPORTED_LOCATION ${LIBSUPCXX_LOCATION})
# libsupc++ requires libgcc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And update this comment as follows:
# libsupc++ requires libgcc and stdc++compat

execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libgcc.a OUTPUT_VARIABLE LIBGCC_LOCATION)
string(STRIP ${LIBGCC_LOCATION} LIBGCC_LOCATION)
set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${LIBGCC_LOCATION})
# libgcc needs kernel32 imports, a CRT and msvcrtex
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and this one as follows:
# libgcc needs winpthread, kernel32, a CRT and msvcrtex imports

tkreuzer added 3 commits June 15, 2024 14:08
__throw_out_of_range_fmt is implemented in libstdc++, but it is needed by libsupc++ and that would mean we would have to link all C++ code to libstdc++.
@tkreuzer tkreuzer force-pushed the RosBE/GCC13-build branch from 1e0829c to 91cf63c Compare June 15, 2024 11:12
add_compile_options(-fno-builtin-sqrt)
add_compile_options(-fno-builtin-sqrtf)
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the other changes (winpthread, gcc-compat, ...) too depend on GCC version? As in unneeded for RosBE's GCC 8.4.0.

@tkreuzer tkreuzer merged commit fcbccaa into reactos:master Jul 9, 2024
@tkreuzer tkreuzer deleted the RosBE/GCC13-build branch July 13, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement For PRs with an enhancement/new feature. GCC-13 Fixes to get ROS build with GCC 13

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants