From: Richard Palethorpe <rpalethorpe@suse.de>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/2] ptrace07: Fix compilation when not on x86
Date: Thu, 20 Oct 2022 11:59:10 +0100 [thread overview]
Message-ID: <87zgdqu4z3.fsf@suse.de> (raw)
In-Reply-To: <d4d411f1-8f07-1fc9-8762-3ab7faa75f24@suse.cz>
Hello,
Martin Doucha <mdoucha@suse.cz> writes:
> On 20. 10. 22 5:53, Li Wang wrote:
>> On Wed, Oct 19, 2022 at 5:30 PM Martin Doucha <mdoucha@suse.cz
>> <mailto:mdoucha@suse.cz>> wrote:
>> Reverting 1df4de06206b079f24dde7157d037b48727c743d is the best solution
>> here. Building ptrace07 and similar arch-specific tests without a key
>> piece of code does not make sense. The preprocessor arch checks should
>> wrap around the whole file, not just a small non-portable bit that's
>> crucial for the test to work.
>> From what I know, one of the uses of "empty macro" is to
>> conditionally
>> include certain portions of a program. In ptrace07, it invokes that useless
>> macro for compiling pass on non-x86 arch but does not allow execute it.
>> I don't see why that's crucial for a test, if we wrap around the
>> whole file and
>> avoid it compiling on non-x86, isn't this essentially same as that?
>> The only distinction between them is partly or wholly skipping the
>> key
>> code compilation. or maybe I completely misunderstood this part.
>
> The code that would be generated by the non-empty version of the macro
> is crucial for rest of the program to work. Putting conditional build
> directives only around a few lines of code can cause bogus warnings
> about uninitialized variables and make it difficult to add more
> arch-specific code like the cpuid_count() macro. There's nothing wrong
> with writing tests like this:
>
> #include "tst_test.h"
>
> #ifdef __x86_64__
> #include "lapi/cpuid.h"
>
> void setup(void)
> {
> ...
> }
>
> void run(void)
> {
> ...
> }
>
> void cleanup(void)
> {
> ...
> }
>
> static struct tst_test test = {
> ...
> .supported_archs = (const char *const []) {
> "x86_64",
> NULL
> },
> };
>
> #else /* __x86_64__ */
> #define TST_TEST_TCONF("this test is only supported on x86_64")
> #endif /* __x86_64__ */
>
>
> IIUC, the metadata parser will still read .supported_archs regardless
> of conditional build directives. And it'll prevent erratic test
> behavior in edge cases where the LTP library believes the code was
> compiled for the right architecture but the GCC preprocessor
> disagrees.
Yes, this sounds reasonable and I will submit a patch for it (on Monday
though).
My remaining concern is that people will include lapi/cpuid.h (or
similar) outside of the ifdef and it will not be caught until it's
merged into master.
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2022-10-20 11:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 15:25 [LTP] [PATCH 1/2] ptrace07: Fix compilation when not on x86 Richard Palethorpe via ltp
2022-10-18 15:25 ` [LTP] [PATCH 2/2] ptrace07: Fix compilation by avoiding aligned_alloc Richard Palethorpe via ltp
2022-10-19 1:40 ` Pengfei Xu
2022-10-19 2:59 ` Li Wang
2022-10-19 3:16 ` Pengfei Xu
2022-10-19 3:20 ` Li Wang
2022-10-19 9:30 ` [LTP] [PATCH 1/2] ptrace07: Fix compilation when not on x86 Martin Doucha
2022-10-20 3:53 ` Li Wang
2022-10-20 7:31 ` Richard Palethorpe
2022-10-20 10:41 ` Martin Doucha
2022-10-20 10:59 ` Richard Palethorpe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgdqu4z3.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=ltp@lists.linux.it \
--cc=mdoucha@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.