Skip to content

Support building on RHEL 8.X#157

Merged
giulianobelinassi merged 1 commit intoSUSE:mainfrom
earnol:main
Oct 13, 2025
Merged

Support building on RHEL 8.X#157
giulianobelinassi merged 1 commit intoSUSE:mainfrom
earnol:main

Conversation

@earnol
Copy link

@earnol earnol commented Oct 10, 2025

Those changes add support for building on RHEL 8.X while preserving compatibility with other build environments.

Adds:

  • More advanced support for outside-of-the-system gcc installations
  • Links with proper runtime in case of gcc installation used for building is different from the system default one.

@giulianobelinassi
Copy link
Collaborator

Hello, @earnol. Thanks for your contribution to clang-extract!

Is it true that in in RHEL the file crtbegin.o is not in the same directory as COLLECT_LTO_WRAPPER/../ ? In that case, it may be better to avoid using COLLECT_LTO_WRAPPER at all and get the directory straight from a gcc compilation:

echo 'int main(){return 0;}' > /tmp/aa.c
gcc -v 2>&1 /tmp/aa.c | tr ' ' '\n' | grep crtbegin.o

which outputs:

/usr/lib64/gcc/x86_64-suse-linux/15/crtbegin.o

from there, running dirname should return the folder. And of course /tmp/aa.c is not a good name for a temporary file, I think meson can generate a random name for it.

I think this is much simpler than attempting many paths and trying to parse which is the correct one.

@earnol
Copy link
Author

earnol commented Oct 13, 2025

Hello @giulianobelinassi,

Well this tool helped me to reduce the particularly large file when c-reduce failed (it did not failed particularly, but i would say it was tricky to use correctly in my situation). So it is logical to have changes i made to adapt to my environment integrated into the upstream.
To answer your questions on RHEL i have following folders:
COLLECT_LTO_WRAPPER folder is:

 ls -al /opt/gcc/13.3.0/libexec/gcc/x86_64-pc-linux-gnu/13.3.0/
total 171016
drwxr-sr-x 4 useruser usergrp     2048 Oct 16  2024 .
drwxr-sr-x 3 useruser usergrp     2048 Oct 16  2024 ..
-rwxr-xr-x 1 useruser usergrp 41364312 Oct 16  2024 cc1
-rwxr-xr-x 1 useruser usergrp 44071744 Oct 16  2024 cc1plus
-rwxr-xr-x 1 useruser usergrp  1598416 Oct 16  2024 collect2
-rwxr-xr-x 1 useruser usergrp 42785080 Oct 16  2024 f951
-rwxr-xr-x 1 useruser usergrp  2030840 Oct 16  2024 g++-mapper-server
drwxr-sr-x 2 useruser usergrp     2048 Oct 16  2024 install-tools
-rwxr-xr-x 1 useruser usergrp     1075 Oct 16  2024 liblto_plugin.la
-rwxr-xr-x 1 useruser usergrp    93368 Oct 16  2024 liblto_plugin.so
-rwxr-xr-x 1 useruser usergrp 40130928 Oct 16  2024 lto1
-rwxr-xr-x 1 useruser usergrp  3031304 Oct 16  2024 lto-wrapper
drwxr-sr-x 2 useruser usergrp     2048 Oct 16  2024 plugin

COLLECT_LTO_WRAPPER/../ has only 1 folder 13.3.0 and nothing more.

The actual crtbegin.o is located in

ls -al /opt/gcc/13.3.0/lib/gcc/x86_64-pc-linux-gnu/13.3.0
total 6531
drwxr-sr-x 8 useruser usergrp    2048 Oct 16  2024 .
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 ..
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 32
-rw-r--r-- 1 useruser usergrp    2472 Oct 16  2024 crtbegin.o
-rw-r--r-- 1 useruser usergrp    2776 Oct 16  2024 crtbeginS.o
-rw-r--r-- 1 useruser usergrp    2992 Oct 16  2024 crtbeginT.o
-rw-r--r-- 1 useruser usergrp    1192 Oct 16  2024 crtend.o
-rw-r--r-- 1 useruser usergrp    1192 Oct 16  2024 crtendS.o
-rw-r--r-- 1 useruser usergrp    3864 Oct 16  2024 crtfastmath.o
-rw-r--r-- 1 useruser usergrp    3544 Oct 16  2024 crtprec32.o
-rw-r--r-- 1 useruser usergrp    3552 Oct 16  2024 crtprec64.o
-rw-r--r-- 1 useruser usergrp    3544 Oct 16  2024 crtprec80.o
drwxr-sr-x 2 useruser usergrp    2048 Oct 16  2024 finclude
drwxr-xr-x 4 useruser usergrp    6144 Oct 16  2024 include
drwxr-xr-x 8 useruser usergrp    2048 Oct 16  2024 include-fixed
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 install-tools
-rw-r--r-- 1 useruser usergrp  151098 Oct 16  2024 libcaf_single.a
-rwxr-xr-x 1 useruser usergrp    1014 Oct 16  2024 libcaf_single.la
-rw-r--r-- 1 useruser usergrp 5863728 Oct 16  2024 libgcc.a
-rw-r--r-- 1 useruser usergrp  328936 Oct 16  2024 libgcc_eh.a
-rw-r--r-- 1 useruser usergrp  289962 Oct 16  2024 libgcov.a
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 plugin

That is why your build file generate wrong path.

Your idea of compilation is good:

gcc -v 2>&1 /tmp/aa.c | tr ' ' '\n' | grep crtbegin.o
/opt/gcc/13.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/13.3.0/crtbegin.o

Which is a correct path. Do you want me to update my pull request with this method?

Those changes add support for building on RHEL 8.X while preserving
compatibility with other build environments.

Adds:
 - More advanced support for outside-of-system gcc installation
 - Links with proper runtime in case of gcc installation used for
   building is different from the system default one.
@giulianobelinassi
Copy link
Collaborator

Hello, @earnol

Hello @giulianobelinassi,

Well this tool helped me to reduce the particularly large file when c-reduce failed (it did not failed particularly, but i would say it was tricky to use correctly in my situation).

If you have any feature request that helps you in your use case, please open an issue about, so we can improve :)

So it is logical to have changes i made to adapt to my environment integrated into the upstream. To answer your questions on RHEL i have following folders: COLLECT_LTO_WRAPPER folder is:

 ls -al /opt/gcc/13.3.0/libexec/gcc/x86_64-pc-linux-gnu/13.3.0/
total 171016
drwxr-sr-x 4 useruser usergrp     2048 Oct 16  2024 .
drwxr-sr-x 3 useruser usergrp     2048 Oct 16  2024 ..
-rwxr-xr-x 1 useruser usergrp 41364312 Oct 16  2024 cc1
-rwxr-xr-x 1 useruser usergrp 44071744 Oct 16  2024 cc1plus
-rwxr-xr-x 1 useruser usergrp  1598416 Oct 16  2024 collect2
-rwxr-xr-x 1 useruser usergrp 42785080 Oct 16  2024 f951
-rwxr-xr-x 1 useruser usergrp  2030840 Oct 16  2024 g++-mapper-server
drwxr-sr-x 2 useruser usergrp     2048 Oct 16  2024 install-tools
-rwxr-xr-x 1 useruser usergrp     1075 Oct 16  2024 liblto_plugin.la
-rwxr-xr-x 1 useruser usergrp    93368 Oct 16  2024 liblto_plugin.so
-rwxr-xr-x 1 useruser usergrp 40130928 Oct 16  2024 lto1
-rwxr-xr-x 1 useruser usergrp  3031304 Oct 16  2024 lto-wrapper
drwxr-sr-x 2 useruser usergrp     2048 Oct 16  2024 plugin

COLLECT_LTO_WRAPPER/../ has only 1 folder 13.3.0 and nothing more.

The actual crtbegin.o is located in

ls -al /opt/gcc/13.3.0/lib/gcc/x86_64-pc-linux-gnu/13.3.0
total 6531
drwxr-sr-x 8 useruser usergrp    2048 Oct 16  2024 .
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 ..
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 32
-rw-r--r-- 1 useruser usergrp    2472 Oct 16  2024 crtbegin.o
-rw-r--r-- 1 useruser usergrp    2776 Oct 16  2024 crtbeginS.o
-rw-r--r-- 1 useruser usergrp    2992 Oct 16  2024 crtbeginT.o
-rw-r--r-- 1 useruser usergrp    1192 Oct 16  2024 crtend.o
-rw-r--r-- 1 useruser usergrp    1192 Oct 16  2024 crtendS.o
-rw-r--r-- 1 useruser usergrp    3864 Oct 16  2024 crtfastmath.o
-rw-r--r-- 1 useruser usergrp    3544 Oct 16  2024 crtprec32.o
-rw-r--r-- 1 useruser usergrp    3552 Oct 16  2024 crtprec64.o
-rw-r--r-- 1 useruser usergrp    3544 Oct 16  2024 crtprec80.o
drwxr-sr-x 2 useruser usergrp    2048 Oct 16  2024 finclude
drwxr-xr-x 4 useruser usergrp    6144 Oct 16  2024 include
drwxr-xr-x 8 useruser usergrp    2048 Oct 16  2024 include-fixed
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 install-tools
-rw-r--r-- 1 useruser usergrp  151098 Oct 16  2024 libcaf_single.a
-rwxr-xr-x 1 useruser usergrp    1014 Oct 16  2024 libcaf_single.la
-rw-r--r-- 1 useruser usergrp 5863728 Oct 16  2024 libgcc.a
-rw-r--r-- 1 useruser usergrp  328936 Oct 16  2024 libgcc_eh.a
-rw-r--r-- 1 useruser usergrp  289962 Oct 16  2024 libgcov.a
drwxr-sr-x 3 useruser usergrp    2048 Oct 16  2024 plugin

That is why your build file generate wrong path.

Ah, so you have a custom-built gcc installed in your system.

Your idea of compilation is good:

gcc -v 2>&1 /tmp/aa.c | tr ' ' '\n' | grep crtbegin.o
/opt/gcc/13.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/13.3.0/crtbegin.o

Which is a correct path. Do you want me to update my pull request with this method?

I see no point in creating the simple_program.c.in file in the project itself since it can be fully generated by the build environment. The command:

$ echo 'int main(){return 0;}' > out.txt

is supported even back to the MS-DOS era. So instead of:

simple_program_file = configure_file(output: 'simple_program.c', input: 'simple_program.c.in', copy: true )

you can simply generate the simple_program.c in the build folder using echo.

@earnol
Copy link
Author

earnol commented Oct 13, 2025

The problem is the code

echo 'int main(){return 0;}' > out.txt

is not cross platform and meson does not support redirection in the run_command.
Granted I use sh -c and it will work, but i have no means to test it under Windows.

@giulianobelinassi
Copy link
Collaborator

Okay, I will approve it then. Thanks for your contribution!

@giulianobelinassi giulianobelinassi merged commit 076fc27 into SUSE:main Oct 13, 2025
8 checks passed
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 this pull request may close these issues.

2 participants