-
Notifications
You must be signed in to change notification settings - Fork 1.5k
greenhills support: fix the asm build error for adapting to greenhills compiler #12883
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
common/gnu/fork.S 29: unknown instruction .syntax unified --^ [asarm] (error apache#2230) common/gnu/fork.S 81: bad directive .type up_fork , function ------------------^ [asarm] (error apache#2067) armv7-m/arm_saveusercontext.S 31: unknown instruction .syntax unified --^ [asarm] (error apache#2230) armv7-m/arm_saveusercontext.S 55: bad directive .type up_saveusercontext , % function --^ [asarm] (error apache#2004) armv7-m/arm_saveusercontext.S 65: not within valid register range str r12 , [ r0 , ( 4 * ( ( ( 12 ) + ( 16 ) ) + 4 ) ) ] ------^ [asarm] (error apache#2004) armv7-m/arm_saveusercontext.S 66: not within valid register range str r14 , [ r0 , ( 4 * ( ( ( 12 ) + ( 16 ) ) + 5 ) ) ] ------^ [asarm] (error apache#2004) armv7-m/arm_saveusercontext.S 67: not within valid register range str r14 , [ r0 , ( 4 * ( ( ( 12 ) + ( 16 ) ) + 6 ) ) ] ------^ [asarm] (error apache#2014) armv7-m/arm_saveusercontext.S 72: expected a register str r1 , [ r0 , ( 4 * ( ( ( 12 ) + ( 16 ) ) + 7 ) ) ] ------------------^ [asarm] (error apache#2004) armv7-m/arm_saveusercontext.S 75: not within valid register range add r1 , r0 , ( 4 * ( ( ( 12 ) + ( 16 ) ) + 8 ) ) -----------^ [asarm] (error apache#2071) armv7-m/arm_saveusercontext.S 89: bad parameter stmia r0 ! , { r2 - r11 } --------^ [asarm] (error apache#2014) armv7-m/arm_saveusercontext.S 93: expected a register mov r1 , - 1 -----------^ Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
The following are the compile error that reported by GreenHills compiler: "/mnt/yang/qixinwei_commit/nuttx/include/arch/syscall.h", line 156 (col. 17): error apache#2036-D: cannot allocate "reg0" to specified caller-saved register "/mnt/yang/qixinwei_commit/nuttx/include/arch/syscall.h", line 157 (col. 17): error apache#2036-D: cannot allocate "reg1" to specified caller-saved register Then we fix this greenhills compilation error by explicitly specifying the registers in the clobber list in the inline assembly code. This fix is successful in compiling on the nuttx/boards/arm/mps/mps2-an500/configs/nsh platform and passes the ostest test. However, if we keep the implementation the same for both the default and Greenhills compilers, the default compiler will report the following two issues: 1. the "sys_call6" function will report compile error when compiling on "./vendor/qemu/boards/smartspeaker/configs/smartspeaker-knsh" platform, the detailed error info: CC: proxies/PROXY_mq_getattr.c In file included from /home/guoshichao/work_profile/vela_os/vela_qemu_1/nuttx/include/sys/syscall.h:35, from /home/guoshichao/work_profile/vela_os/vela_qemu_1/nuttx/include/syscall.h:30, from proxies/PROXY_mmap.c:5: In function 'sys_call6', inlined from 'mmap' at proxies/PROXY_mmap.c:9:22: /home/guoshichao/work_profile/vela_os/vela_qemu_1/nuttx/include/arch/syscall.h:297:3: error: 'asm' operand has impossible constraints 297 | __asm__ __volatile__ | ^~~~~~~ 2. when running on qemu-armv7-a platform, the modification to "smh_call()" function will make the system fail to boot up, so we need to keep the default compiler implementation and greenhills compiler implementation separate Signed-off-by: fangxinyong <fangxinyong@xiaomi.com> (cherry picked from commit cb48b74)
according to armv6-m/armv7-m arch reference manual:
the three ISB {<opt>}, DSB {<opt>}, DMB {<opt>} instructions <opt>
field are defined as:
Specifies an optional limitation on the ISB/DSB/DMB operation. Allowered
values are:
Full system ISB/DSB/DMB operation, encoded as option=='1111'. Can be
omitted.
All other encodings of the options are RESERVED.
the "#opt" field of "isb #opt"
So we could remove the options field in Armv7-m platform.
The following are the build error with greenhills compiler:
CC: common/arm_exit.c [asarm] (error apache#2071) /tmp/gh_001h70j1.si 92: bad parameter
isb 15
------^
[asarm] (error apache#2071) /tmp/gh_001h70j1.si 112: bad parameter
isb 15
------^
[asarm] (error) errors during processing
According to armv8-m arch reference manual:
the ISB/DMB instruction's "opt" encoding rule is same as
armv6-m/armv7-m, but the "DSB" instruction is different, in armv8-m, the
"DSB {<opt>}" field has two valid encoding options: 0b0000, 0b0100.
and all other encoding options are reserved.
In Armv7-a/Armv8-a, the dsb/dmb option field has 8 valid state value.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
CC: bch/bchlib_read.c [asarm] (error apache#2067) machine/arm/gnu/arch_setjmp.S 34: unknown instruction .syntax unified --^ [asarm] (error apache#2230) machine/arm/gnu/arch_setjmp.S 62: bad directive .type setjmp , function -----------------^ [asarm] (error) errors during processing Signed-off-by: guoshichao <guoshichao@xiaomi.com>
CC: assert/lib_assert.c [asarm] (error apache#2179) modlib/modlib_globals.S 61: unexpected token type (char) encountered; expected type (identifier) .size \ globalNames , . - \ globalNames --------^ [asarm] (error apache#2179) modlib/modlib_globals.S 67: unexpected token type (char) encountered; expected type (identifier) .size \ nglobals , . - \ nglobals --------^ [asarm] (error apache#2179) modlib/modlib_globals.S 72: unexpected token type (char) encountered; expected type (identifier) .size \ global_table , . - \ global_table --------^ Signed-off-by: guoshichao <guoshichao@xiaomi.com>
"/mnt/yang/qixinwei_vela_warnings/nuttx/include/nuttx/spinlock.h", line 252: warning apache#76-D: argument to macro is empty SP_DSB(); ^ "/mnt/yang/qixinwei_vela_warnings/nuttx/include/nuttx/spinlock.h", line 261: warning apache#76-D: argument to macro is empty SP_DMB(); ^ "/mnt/yang/qixinwei_vela_warnings/nuttx/include/nuttx/spinlock.h", line 252: warning apache#76-D: argument to macro is empty SP_DSB(); ^ "/mnt/yang/qixinwei_vela_warnings/nuttx/include/nuttx/spinlock.h", line 261: warning apache#76-D: argument to macro is empty SP_DMB(); ^ "/mnt/yang/qixinwei_vela_warnings/nuttx/include/nuttx/spinlock.h", line 296: warning apache#76-D: argument to macro is empty SP_DSB(); ^ Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
acassis
approved these changes
Aug 11, 2024
anchao
reviewed
Aug 12, 2024
Contributor
|
@extinguish @xiaoxiang781216 see my inline comments |
xiezhanpeng2025
added a commit
to xiezhanpeng2025/nuttx
that referenced
this pull request
Nov 12, 2025
…r arm-v8r The GreenHills Compiler uses different grammer for the .type directive in asm, this patch adds support for the grammer for arm-v8r. Similar change for arm-v7r was done in pull request apache#12883. Signed-off-by: xiezhanpeng3 <xiezhanpeng3@lixiang.com>
xiezhanpeng2025
added a commit
to xiezhanpeng2025/nuttx
that referenced
this pull request
Nov 12, 2025
…r arm-v8r The GreenHills Compiler uses different grammer for the .type directive in asm, this patch adds support for the grammer for arm-v8r. Similar change for arm-v7r was done in pull request apache#12883. Co-authored-by: Chengdong Wang <wangchengdong@lixiang.com> Signed-off-by: xiezhanpeng3 <xiezhanpeng3@lixiang.com>
xiezhanpeng2025
added a commit
to xiezhanpeng2025/nuttx
that referenced
this pull request
Nov 13, 2025
…r arm-v8r The GreenHills Compiler uses different grammer for the .type directive in asm, this patch adds support for the grammer for arm-v8r. Similar change for arm-v7r was done in pull request apache#12883. Co-authored-by: Chengdong Wang <wangchengdong@lixiang.com> Signed-off-by: xiezhanpeng3 <xiezhanpeng3@lixiang.com>
xiaoxiang781216
pushed a commit
that referenced
this pull request
Nov 13, 2025
…r arm-v8r The GreenHills Compiler uses different grammer for the .type directive in asm, this patch adds support for the grammer for arm-v8r. Similar change for arm-v7r was done in pull request #12883. Co-authored-by: Chengdong Wang <wangchengdong@lixiang.com> Signed-off-by: xiezhanpeng3 <xiezhanpeng3@lixiang.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Impact
Testing