[PATCH 2/2] semihosting/uaccess: Compile once

Philippe Mathieu-Daudé posted 2 patches 7 months, 2 weeks ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>
There is a newer version of this series
[PATCH 2/2] semihosting/uaccess: Compile once
Posted by Philippe Mathieu-Daudé 7 months, 2 weeks ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 semihosting/meson.build | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/semihosting/meson.build b/semihosting/meson.build
index f3d38dda91d..a0a1c081f43 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -3,9 +3,7 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
   'syscalls.c',
 ))
 
-specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files(
-  'uaccess.c',
-))
+libsystem_ss.add(files('uaccess.c'))
 
 common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
 user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c'))
-- 
2.47.1


Re: [PATCH 2/2] semihosting/uaccess: Compile once
Posted by Pierrick Bouvier 7 months, 2 weeks ago
On 5/2/25 3:05 PM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   semihosting/meson.build | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/semihosting/meson.build b/semihosting/meson.build
> index f3d38dda91d..a0a1c081f43 100644
> --- a/semihosting/meson.build
> +++ b/semihosting/meson.build
> @@ -3,9 +3,7 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
>     'syscalls.c',
>   ))
>   
> -specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files(
> -  'uaccess.c',
> -))
> +libsystem_ss.add(files('uaccess.c'))
>   
>   common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
>   user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c'))

Fails to build with:
./configure --disable-tcg && ninja -C build
FAILED: libsystem.a.p/semihosting_uaccess.c.o
../semihosting/uaccess.c
../semihosting/uaccess.c: In function ‘uaccess_strlen_user’:
../semihosting/uaccess.c:43:17: error: implicit declaration of function 
‘probe_access_flags’ [-Wimplicit-function-declaration]
     43 |         flags = probe_access_flags(env, addr, 0, MMU_DATA_LOAD,
        |                 ^~~~~~~~~~~~~~~~~~
../semihosting/uaccess.c:43:17: error: nested extern declaration of 
‘probe_access_flags’ [-Werror=nested-externs]

CONFIG_SEMIHOSTING conditional must be kept.
-libsystem_ss.add(files('uaccess.c'))
+libsystem_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('uaccess.c'))

However, it will fail as libsystem cannot apply target configuration for 
now, so we need to modify its definition (and libuser while we are at it).
Please apply the two patches attached (only the second is needed 
strictly, but it's currently stacked on the first one in my series for 
target/arm). I'll post it as well when updating my series.