Skip to content

cmake:fix protected build link option break,init canmv230 protected build #12022

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

Closed
wants to merge 1 commit into from

Conversation

xuxin930
Copy link
Contributor

Summary

this should resolve #12019 (comment)

the link_option of nuttx_user target should be allowed to be set freely

Impact

protected mode

Testing

cmake -B build -DBOARD_CONFIG=canmv230/pnsh

cmake --build build 

@acassis
Copy link
Contributor

acassis commented Mar 29, 2024

@xuxin930 @xiaoxiang781216 any idea why the CI reported this issue many times:

Check failure on line 51 in include/nuttx/wdog.h
GitHub Actions / macOS (macos)

missing binary operator before token "("

@simbit18
Copy link
Contributor

simbit18 commented Mar 29, 2024

@acassis @xiaoxiang781216 The problem is here
https://github.com/apache/nuttx/actions/runs/8479414330/job/23233475816?pr=12022#step:7:1313
Configuring...
make: *** [olddefconfig] Error 1
Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
make: *** [olddefconfig] Error 1

I think clearing the cache solves the problem
https://github.com/apache/nuttx/actions/caches

@xuxin930
Copy link
Contributor Author

@acassis @xiaoxiang781216 The problem is here https://github.com/apache/nuttx/actions/runs/8479414330/job/23233475816?pr=12022#step:7:1313 Configuring... make: *** [olddefconfig] Error 1 Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI make: *** [olddefconfig] Error 1

I think clearing the cache solves the problem https://github.com/apache/nuttx/actions/caches

@acassis @simbit18
It seems that similar situations have happened before
refer to: #10543

@simbit18
Copy link
Contributor

@xuxin930 exactly !!! cache must be cleared manually.

set_target_properties(nuttx_user PROPERTIES LINK_OPTIONS "")
# deleted Toolchain link options
get_target_property(nuttx_user_LINK_OPTIONS nuttx_user LINK_OPTIONS)
list(REMOVE_ITEM nuttx_user_LINK_OPTIONS "-Wl,--gc-sections")
Copy link
Contributor

Choose a reason for hiding this comment

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

why not skip adding these option instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not skip adding these option instead

These link options is set in the Toolchain file and has global scope.
they are also required by the nuttx target.but the timing of setting the Toolchain file is before all targets.
so it cannot be distinguished by USER_LINK_OPTION and NUTTX_LINK_OPTION like Makefile.

Copy link
Contributor

Choose a reason for hiding this comment

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

why these options can't be used with uerspace.bin

Copy link
Contributor

@yf13 yf13 Jul 11, 2024

Choose a reason for hiding this comment

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

I don't know how @xuxin930 identified them. My test shows that the gc-sections will cause user space ELF lacking things required by kernel side, thus can't boot the target. The -Map=nuttx.map name conflicts with that of kernel. As these global settings are for kernel, adjusting them for userspace looks reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

@xuxin930 let's split the hack to a new pr

@yf13
Copy link
Contributor

yf13 commented Apr 5, 2024

@xuxin930

I tried this and it works, the artifact runs on CanMV230 device as well:

ABC                                                                             
NuttShell (NSH) NuttX-12.4.0                                                    
nsh> cat /proc/version                                                          
NuttX version 12.4.0 da63218c4d Apr  5 2024 08:03:09 canmv230/pnsh
nsh> free                                                                       
                   total       used       free    maxused    maxfree  nused  nfree                                                                              
        Kmem:    1034232       5816    1028416       6408    1028368     16     2                                                                              
        Umem:    1045112       6040    1039072       6040    1039072      9     1 

Only one minor issue met during CMake configuration process:

$ rm -rf * && cmake ~/Projects/Nuttx/nuttx -DBOARD_CONFIG=canmv230/pnsh -G Ninja 
-- Initializing NuttX
--   Board:  canmv230
--   Config: pnsh
--   Appdir: /home/yf/Projects/Nuttx/nuttx/../apps
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/riscv64-unknown-elf-gcc
riscv64-unknown-elf-gcc: error:  -Wstrict-prototypes -fno-common -Wall -Wshadow -Wundef -Wno-attributes -Wno-unknown-pragmas: No such file or directory
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yf/tmp/bbb

@yf13
Copy link
Contributor

yf13 commented Jul 11, 2024

@xuxin930,

Here I tried this again with GCC toolchain v10.2 got via apt install gcc-riscv64-unknown-elf on Ubuntu.

It seems that we can avoid the above cmake config time warning by dropping the CMAKE_C_FLAGS from the libgcc checking command in line 755.

@xiaoxiang781216
Copy link
Contributor

@xuxin930 should we rebase the code

@xuxin930
Copy link
Contributor Author

@xuxin930 should we rebase the code

Done, rebased

@xuxin930
Copy link
Contributor Author

CI seems failed because fetch timeout
try retrigger

@xuxin930 xuxin930 marked this pull request as draft September 19, 2024 03:39
@xuxin930 xuxin930 closed this Oct 12, 2024
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.

riscv/cmake: protected mode issue
6 participants