diff mbox series

[1/2] hugemmap15: Compile with -O

Message ID 20230125222703.19943-2-pvorel@suse.cz
State Changes Requested
Headers show
Series hugemmap15 pre-release testing | expand

Commit Message

Petr Vorel Jan. 25, 2023, 10:27 p.m. UTC
-O0 originally used causes warning on gcc 12:

In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from hugemmap15.c:22:
/usr/include/features.h:412:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  412 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)

Fixes: 15625f6185 ("Hugetlb: Migrating libhugetlbfs icache-hygiene")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tarun Sahu Jan. 26, 2023, 9:05 p.m. UTC | #1
Hi Petr, Cyril, all

Though It already got merged, please note this,

IIRC, I specifically turned off optimization for hugemmap15
because of clang compiler issue, it behaves weirdly with clang
without -O0 and test fails on the system.

Petr Vorel <pvorel@suse.cz> writes:

> -O0 originally used causes warning on gcc 12:
>
> In file included from /usr/include/bits/libc-header-start.h:33,
>                  from /usr/include/stdio.h:27,
>                  from hugemmap15.c:22:
> /usr/include/features.h:412:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
>   412 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
>
> Fixes: 15625f6185 ("Hugetlb: Migrating libhugetlbfs icache-hygiene")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/kernel/mem/hugetlb/hugemmap/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> index 6f10807cde..503a35f7f1 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> @@ -8,5 +8,5 @@ include $(top_srcdir)/include/mk/testcases.mk
>  include $(abs_srcdir)/../Makefile.inc
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
>  
> -hugemmap15: CFLAGS+=-O0
> +hugemmap15: CFLAGS+=-O
>  hugemmap06: CFLAGS+=-pthread
> -- 
> 2.39.1
>
>
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Petr Vorel Jan. 26, 2023, 11 p.m. UTC | #2
Hi Tarun,

> Hi Petr, Cyril, all

> Though It already got merged, please note this,
FYI this has not been merged (only the second patch "hugemmap15: Use
TST_TEST_TCONF() for unsupported archs", which was needed to fix compilations).

> IIRC, I specifically turned off optimization for hugemmap15
> because of clang compiler issue, it behaves weirdly with clang
> without -O0 and test fails on the system.

Isn't -O the same as -O0 ?

Kind regards,
Petr
Tarun Sahu Jan. 26, 2023, 11:38 p.m. UTC | #3
Petr Vorel <pvorel@suse.cz> writes:

> Hi Tarun,
>
>> Hi Petr, Cyril, all
>
>> Though It already got merged, please note this,
> FYI this has not been merged (only the second patch "hugemmap15: Use
> TST_TEST_TCONF() for unsupported archs", which was needed to fix compilations).

Ok.
>
>> IIRC, I specifically turned off optimization for hugemmap15
>> because of clang compiler issue, it behaves weirdly with clang
>> without -O0 and test fails on the system.
>
> Isn't -O the same as -O0 ?
I think -O is -O1.

I tested with clang with -O, it fails. So yeah it is not turning off
relevant optimization.

>
> Kind regards,
> Petr
>
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Petr Vorel Jan. 27, 2023, 8:28 a.m. UTC | #4
Hi all,

> >> Though It already got merged, please note this,
> > FYI this has not been merged (only the second patch "hugemmap15: Use
> > TST_TEST_TCONF() for unsupported archs", which was needed to fix compilations).

> Ok.
And don't worry, this will not be merged before release,
which is going to happen hopefully today (or on Monday).

> >> IIRC, I specifically turned off optimization for hugemmap15
> >> because of clang compiler issue, it behaves weirdly with clang
> >> without -O0 and test fails on the system.

> > Isn't -O the same as -O0 ?
> I think -O is -O1.
Yes, -O Equivalent to -O1 [1].

> I tested with clang with -O, it fails. So yeah it is not turning off
> relevant optimization.

Yes, you're right. It worked for me, but after full cleanup it really failed
with -O or -O1 (at least on x86_64 on clang 15.0.7).

@Cyril: I wonder why we need
1) -D_FORTIFY_SOURCE=2 for all (in CPPFLAGS), defined in m4/ltp-fortify_source.m4,
this will warn, when we need to disable optimisation for some test?
-D_FORTIFY_SOURCE=0 obviously warn for redefinition.
It was added in 2013 (4b3007a8e1), not sure which glibc version required it, but
maybe time to drop it? (after release of course)
2) to use CPPFLAGS and CFLAGS together?

Kind regards,
Petr

[1] https://clang.llvm.org/docs/CommandGuide/clang.html
Cyril Hrubis Jan. 27, 2023, 9:20 a.m. UTC | #5
Hi!
> I tested with clang with -O, it fails. So yeah it is not turning off
> relevant optimization.

There seems to be pragma to turn off optimizations only for clang, can
you try if adding:

#pragma clang optimize off

to the source and removeing the -O0 from the Makefile works?
Tarun Sahu Feb. 10, 2023, 10:04 p.m. UTC | #6
Cyril Hrubis <chrubis@suse.cz> writes:

Hi Cyril,

I tested with pragma, This works well.
Will send a patch.

Thanks
Tarun
> Hi!
>> I tested with clang with -O, it fails. So yeah it is not turning off
>> relevant optimization.
>
> There seems to be pragma to turn off optimizations only for clang, can
> you try if adding:
>
> #pragma clang optimize off
>
> to the source and removeing the -O0 from the Makefile works?
>
> -- 
> Cyril Hrubis
> chrubis@suse.cz
>
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
diff mbox series

Patch

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
index 6f10807cde..503a35f7f1 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
@@ -8,5 +8,5 @@  include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-hugemmap15: CFLAGS+=-O0
+hugemmap15: CFLAGS+=-O
 hugemmap06: CFLAGS+=-pthread