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

cmake: silence "LOAD segment with RWX permissions" warning #167

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

marckleinebudde
Copy link
Contributor

Link: #106

@marckleinebudde
Copy link
Contributor Author

@fenugrec my compiler doesn't support --no-warn-rwx-segments and cmake doesn't use the new option. Does it fix the warning with your compiler?

@marckleinebudde
Copy link
Contributor Author

Debian stable ("bullseye") uses cmake-3.18, Debian oldstable ("buster") is still on cmake-3.13, but "buster-backports" has cmake-3.18, too.

@fenugrec fenugrec added the Ready for merge When contents have been reviewed and can be merged by any maintainer label Jan 24, 2024
@fenugrec
Copy link
Collaborator

I think bumping required to 3.18 is reasonable; distros with really old cmake have a simple workaround of just reverting this commit.

@fenugrec fenugrec removed the Ready for merge When contents have been reviewed and can be merged by any maintainer label Jan 24, 2024
@fenugrec
Copy link
Collaborator

Oops, actual test doesn't quite work as is, two issues - cmake invokes gcc for the link step, so the arg needs to be -Wl,--no-warn-rwx-segments . Second issue is trickier, cmake fails its compile test :

        Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_318a8/fast
        make[1]: Entering directory '/home/q/d/can/candleLight_fw/build/CMakeFiles/CMakeScratch/TryCompile-nTjHd2'
        /usr/bin/make  -f CMakeFiles/cmTC_318a8.dir/build.make CMakeFiles/cmTC_318a8.dir/build
        make[2]: Entering directory '/home/q/d/can/candleLight_fw/build/CMakeFiles/CMakeScratch/TryCompile-nTjHd2'
        Building C object CMakeFiles/cmTC_318a8.dir/src.c.obj
        /usr/bin/arm-none-eabi-gcc -DLINKER_SUPPORTS_NO_WARN_RWX_SEGMENTS   -o CMakeFiles/cmTC_318a8.dir/src.c.obj -c /home/q/d/can/candleLight_fw/build/CMakeFiles/CMakeScratch/TryCompile-nTjHd2/src.c
        Linking C executable cmTC_318a8
        /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_318a8.dir/link.txt --verbose=1
        /usr/bin/arm-none-eabi-gcc -Wl,--no-warn-rwx-segments CMakeFiles/cmTC_318a8.dir/src.c.obj -o cmTC_318a8 
        /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/libc.a(libc_a-exit.o): in function `exit':
        /build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/newlib/../../../newlib-4.3.0.20230120/newlib/libc/stdlib/exit.c:65:(.text.exit+0x28): undefined reference to `_exit'
        /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/libc.a(libc_a-closer.o): in function `_close_r':
        /build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/newlib/../../../newlib-4.3.0.20230120/newlib/libc/reent/closer.c:47:(.text._close_r+0x18): undefined reference to `_close'
        /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/libc.a(libc_a-lseekr.o): in function `_lseek_r':
        /build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/newlib/../../../newlib-4.3.0.20230120/newlib/libc/reent/lseekr.c:49:(.text._lseek_r+0x24): undefined reference to `_lseek'
        /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/libc.a(libc_a-readr.o): in function `_read_r':
        /build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/newlib/../../../newlib-4.3.0.20230120/newlib/libc/reent/readr.c:49:(.text._read_r+0x24): undefined reference to `_read'
        /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/libc.a(libc_a-writer.o): in function `_write_r':
        /build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/newlib/../../../newlib-4.3.0.20230120/newlib/libc/reent/writer.c:49:(.text._write_r+0x24): undefined reference to `_write'
        /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/libc.a(libc_a-sbrkr.o): in function `_sbrk_r':
        /build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/newlib/../../../newlib-4.3.0.20230120/newlib/libc/reent/sbrkr.c:51:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
        collect2: error: ld returned 1 exit status
        make[2]: *** [CMakeFiles/cmTC_318a8.dir/build.make:99: cmTC_318a8] Error 1
        make[2]: Leaving directory '/home/q/d/can/candleLight_fw/build/CMakeFiles/CMakeScratch/TryCompile-nTjHd2'
        make[1]: *** [Makefile:127: cmTC_318a8/fast] Error 2
        make[1]: Leaving directory '/home/q/d/can/candleLight_fw/build/CMakeFiles/CMakeScratch/TryCompile-nTjHd2'

We're also getting those super annoying warnings about _write etc. not being implemented on master as well but seems here they are causing a link failure. No time to mess with this atm.

@marckleinebudde marckleinebudde force-pushed the fix-LOAD-segment-with-RWX-permissions branch from 2141cec to 31ce5dc Compare January 24, 2024 16:38
@marckleinebudde
Copy link
Contributor Author

marckleinebudde commented Jan 24, 2024

Thanks for testing! Fixed the first issue, add missing LINKER:.

I see a undefined reference to _exit'` here, too:

        /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5ff6a.dir/link.txt --verbose=1
        /usr/lib/ccache/arm-none-eabi-gcc -Wl,--no-warn-rwx-segments CMakeFiles/cmTC_5ff6a.dir/src.c.obj -o cmTC_5ff6a
        /usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
        /build/newlib-afIbHz/newlib-3.3.0/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/exit.c:64:(.text+0x2c): undefined reference to `_exit'

but it correctly detects support for --no-warn-rwx-segments:

    buildResult:
      variable: "LINKER_SUPPORTS_NO_WARN_RWX_SEGMENTS"
      cached: true

@fenugrec
Copy link
Collaborator

Fixed.

Thanks, youǜve fixed the passing-wrong-arg problem, but since the test compilation fails, cmake still thinks the flag is "not supported"

@marckleinebudde
Copy link
Contributor Author

Just noticed, too. But why does it say cached: true.

@fenugrec
Copy link
Collaborator

fenugrec commented Jan 24, 2024

But why does it say cached: true.

AFAIK because https://cmake.org/cmake/help/latest/module/CheckLinkerFlag.html

Stores the result in an internal cache entry named <var>

@marckleinebudde marckleinebudde force-pushed the fix-LOAD-segment-with-RWX-permissions branch from 31ce5dc to 750452e Compare January 25, 2024 12:32
Fixes: 89c44fe ("correct LED initialization for canable interfaces")
This way uncrustify produces better indention.
This way uncrustify produces better indention.
This increases the size of the binary in a stm32f072 a bit:

before:
Memory region         Used Size  Region Size  %age Used
           FLASH:       17296 B       128 KB     13.20%
             RAM:        4268 B        16 KB     26.05%

after:
Memory region         Used Size  Region Size  %age Used
           FLASH:       17312 B       128 KB     13.21%
             RAM:        4268 B        16 KB     26.05%

Closes: candle-usb#164
@marckleinebudde marckleinebudde force-pushed the fix-LOAD-segment-with-RWX-permissions branch from 750452e to 62141db Compare June 4, 2024 19:13
This is the default for yml files for the github workflows.
Use containers to build on various Debian based distributions:

- Ubuntu: 20.04
- Ubuntu: 22.04
- Ubuntu: 24.04
- Ubuntu: rolling
- Debian: oldstable
- Debian: stable
- Debian: testing
- Debian: unstable
@marckleinebudde marckleinebudde force-pushed the fix-LOAD-segment-with-RWX-permissions branch from 62141db to 19d7a76 Compare June 4, 2024 19:32
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