linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v3 3/4] tools/nolibc: implement fd-based FILE streams
       [not found] ` <20230328-nolibc-printf-test-v3-3-ddc79f92efd5@weissschuh.net>
@ 2023-04-12 15:58   ` Mark Brown
  2023-04-13 13:09     ` linux
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2023-04-12 15:58 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest,
	linux-arm-kernel, linux-next

[-- Attachment #1: Type: text/plain, Size: 2911 bytes --]

On Sun, Apr 02, 2023 at 06:04:36PM +0000, Thomas Weißschuh wrote:

> This enables the usage of the stream APIs with arbitrary filedescriptors.
> 
> It will be used by a future testcase.

This breaks the explicit use of standard streams:

> -static __attribute__((unused)) FILE* const stdin  = (FILE*)-3;
> -static __attribute__((unused)) FILE* const stdout = (FILE*)-2;
> -static __attribute__((unused)) FILE* const stderr = (FILE*)-1;
> +static __attribute__((unused)) FILE* const stdin  = (FILE*)(intptr_t)~STDIN_FILENO;
> +static __attribute__((unused)) FILE* const stdout = (FILE*)(intptr_t)~STDOUT_FILENO;
> +static __attribute__((unused)) FILE* const stderr = (FILE*)(intptr_t)~STDERR_FILENO;

Nothing in this change (or anything else in the series AFAICT) causes
STDx_FILENO to be declared so we get errors like below in -next when a
kselftest is built with this version of nolibc:

clang --target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument --target=aarch64-linux-gnu -fintegrated-as -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
	-include ../../../../include/nolibc/nolibc.h -I../..\
	-static -ffreestanding -Wall za-fork.c /tmp/kci/linux/build/kselftest/arm64/fp/za-fork-asm.o -o /tmp/kci/linux/build/kselftest/arm64/fp/za-fork
In file included from <built-in>:1:
In file included from ./../../../../include/nolibc/nolibc.h:97:
In file included from ./../../../../include/nolibc/arch.h:25:
./../../../../include/nolibc/arch-aarch64.h:176:35: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <built-in>:1:
In file included from ./../../../../include/nolibc/nolibc.h:102:
./../../../../include/nolibc/stdio.h:33:71: error: use of undeclared identifier 'STDIN_FILENO'
static __attribute__((unused)) FILE* const stdin  = (FILE*)(intptr_t)~STDIN_FILENO;
                                                                      ^
./../../../../include/nolibc/stdio.h:34:71: error: use of undeclared identifier 'STDOUT_FILENO'
static __attribute__((unused)) FILE* const stdout = (FILE*)(intptr_t)~STDOUT_FILENO;
                                                                      ^
./../../../../include/nolibc/stdio.h:35:71: error: use of undeclared identifier 'STDERR_FILENO'
static __attribute__((unused)) FILE* const stderr = (FILE*)(intptr_t)~STDERR_FILENO;
                                                                      ^
1 warning and 3 errors generated.

The kselftest branch itself is fine, the issues manifest when it is
merged with the nolibc branch.  I'm not quite sure what the implicit
include that's been missed here is?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 3/4] tools/nolibc: implement fd-based FILE streams
  2023-04-12 15:58   ` [PATCH v3 3/4] tools/nolibc: implement fd-based FILE streams Mark Brown
@ 2023-04-13 13:09     ` linux
  2023-04-13 14:20       ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: linux @ 2023-04-13 13:09 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Weißschuh, Willy Tarreau, Shuah Khan, linux-kernel,
	linux-kselftest, linux-arm-kernel, linux-next

Hi Mark,


Apr 12, 2023 17:58:45 Mark Brown <broonie@kernel.org>:

> On Sun, Apr 02, 2023 at 06:04:36PM +0000, Thomas Weißschuh wrote:
>
>> This enables the usage of the stream APIs with arbitrary filedescriptors.
>>
>> It will be used by a future testcase.
>
> This breaks the explicit use of standard streams:
>
>> -static __attribute__((unused)) FILE* const stdin  = (FILE*)-3;
>> -static __attribute__((unused)) FILE* const stdout = (FILE*)-2;
>> -static __attribute__((unused)) FILE* const stderr = (FILE*)-1;
>> +static __attribute__((unused)) FILE* const stdin  = (FILE*)(intptr_t)~STDIN_FILENO;
>> +static __attribute__((unused)) FILE* const stdout = (FILE*)(intptr_t)~STDOUT_FILENO;
>> +static __attribute__((unused)) FILE* const stderr = (FILE*)(intptr_t)~STDERR_FILENO;
>
> Nothing in this change (or anything else in the series AFAICT) causes
> STDx_FILENO to be declared so we get errors like below in -next when a
> kselftest is built with this version of nolibc:

These definitions come from
"tools/nolibc: add definitions for standard fds".
This patch was part of the nolibc stack protector series which is older than this series and went through the same channels.
So I'm not sure how one series made it into next and the other didn't.

This would also have been noticed by Willy and Paul running their tests.

>
> clang --target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument --target=aarch64-linux-gnu -fintegrated-as -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
>     -include ../../../../include/nolibc/nolibc.h -I../..\
>     -static -ffreestanding -Wall za-fork.c /tmp/kci/linux/build/kselftest/arm64/fp/za-fork-asm.o -o /tmp/kci/linux/build/kselftest/arm64/fp/za-fork
> In file included from <built-in>:1:
> In file included from ./../../../../include/nolibc/nolibc.h:97:
> In file included from ./../../../../include/nolibc/arch.h:25:
> ./../../../../include/nolibc/arch-aarch64.h:176:35: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
> void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
>                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from <built-in>:1:
> In file included from ./../../../../include/nolibc/nolibc.h:102:
> ./../../../../include/nolibc/stdio.h:33:71: error: use of undeclared identifier 'STDIN_FILENO'
> static __attribute__((unused)) FILE* const stdin  = (FILE*)(intptr_t)~STDIN_FILENO;
>                                                                       ^
> ./../../../../include/nolibc/stdio.h:34:71: error: use of undeclared identifier 'STDOUT_FILENO'
> static __attribute__((unused)) FILE* const stdout = (FILE*)(intptr_t)~STDOUT_FILENO;
>                                                                       ^
> ./../../../../include/nolibc/stdio.h:35:71: error: use of undeclared identifier 'STDERR_FILENO'
> static __attribute__((unused)) FILE* const stderr = (FILE*)(intptr_t)~STDERR_FILENO;
>                                                                       ^
> 1 warning and 3 errors generated.
>
> The kselftest branch itself is fine, the issues manifest when it is
> merged with the nolibc branch.  I'm not quite sure what the implicit> include that's been missed here is?

These defines should be available to all users of nolibc.
It seems more of an issue with the patchsets going through different trees.

I can investigate this more tomorrow with my proper development setup.

Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 3/4] tools/nolibc: implement fd-based FILE streams
  2023-04-13 13:09     ` linux
@ 2023-04-13 14:20       ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2023-04-13 14:20 UTC (permalink / raw)
  To: linux
  Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest,
	linux-arm-kernel, linux-next

[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]

On Thu, Apr 13, 2023 at 03:09:27PM +0200, linux@weissschuh.net wrote:
> Apr 12, 2023 17:58:45 Mark Brown <broonie@kernel.org>:

> > Nothing in this change (or anything else in the series AFAICT) causes
> > STDx_FILENO to be declared so we get errors like below in -next when a
> > kselftest is built with this version of nolibc:

> These definitions come from
> "tools/nolibc: add definitions for standard fds".
> This patch was part of the nolibc stack protector series which is older than this series and went through the same channels.
> So I'm not sure how one series made it into next and the other didn't.

> This would also have been noticed by Willy and Paul running their tests.

Hrm, that commit is actually in -next and Paul's pull request, not sure
why it wasn't showing up in greps.  The issue is that you've added a
dependency from nolibc's stdio.h to unistd.h but nolibc.h includes
unistd.h last and there's no other include, meaning that at the time
that stdio.h is compiled there's no definition of the constants visible.

The below fixes the issue, I'll submit it properly later today:

diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 04739a6293c4..05a228a6ee78 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -99,11 +99,11 @@
 #include "sys.h"
 #include "ctype.h"
 #include "signal.h"
+#include "unistd.h"
 #include "stdio.h"
 #include "stdlib.h"
 #include "string.h"
 #include "time.h"
-#include "unistd.h"
 #include "stackprotector.h"
 
 /* Used by programs to avoid std includes */

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-13 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230328-nolibc-printf-test-v3-0-ddc79f92efd5@weissschuh.net>
     [not found] ` <20230328-nolibc-printf-test-v3-3-ddc79f92efd5@weissschuh.net>
2023-04-12 15:58   ` [PATCH v3 3/4] tools/nolibc: implement fd-based FILE streams Mark Brown
2023-04-13 13:09     ` linux
2023-04-13 14:20       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).