All of lore.kernel.org
 help / color / mirror / Atom feed
* error: impossible constraint in 'asm' when compiling kernel code with -O0 option
@ 2021-10-06  2:58 ckim
  2021-10-06  5:54 ` Jeffrey Walton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ckim @ 2021-10-06  2:58 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 2891 bytes --]

In linux-5.4.21 code,

To prevent some variables from being 'optimized out' during kernel code
analysis using gdb, I added in drivers/iommu/Makefile,

(replacing -O2 flags to -O0 flags for some files,  I found
http://www.joelfernandes.org/linux/2018/06/10/kernel-gdb.html )

CFLAGS_REMOVE_arm-smmu.o := -O2

CFLAGS_REMOVE_arm-smmu-impl.o := -O2

CFLAGS_REMOVE_io-pgtable-arm-v7s.o := -O2

CFLAGS_REMOVE_io-pgtable-arm.o := -O2

CFLAGS_REMOVE_of_iommu.o := -O2

CFLAGS_REMOVE_arm-smmu-v3.o := -O2

CFLAGS_arm-smmu.o := -O0

CFLAGS_arm-smmu-impl.o := -O0

CFLAGS_io-pgtable-arm-v7s.o := -O0

CFLAGS_io-pgtable-arm.o := -O0

CFLAGS_of_iommu.o := -O0

CFLAGS_arm-smmu-v3.o := -O0

But when I do make ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- Image, I get

CALL    scripts/checksyscalls.sh

  CALL    scripts/atomic/check-atomics.sh

  CHK     include/generated/compile.h

  CC      drivers/iommu/io-pgtable-arm.o

In file included from ././include/linux/compiler_types.h:68,

                 from <command-line>:

./arch/arm64/include/asm/jump_label.h: In function
'system_uses_lse_atomics':

./include/linux/compiler-gcc.h:120:38: warning: asm operand 0 probably
doesn't match constraints

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

./include/linux/compiler-gcc.h:120:38: warning: asm operand 0 probably
doesn't match constraints

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

make[2]: *** [scripts/Makefile.build:266: drivers/iommu/io-pgtable-arm.o]
Error 1

make[1]: *** [scripts/Makefile.build:509: drivers/iommu] Error 2

make: *** [Makefile:1652: drivers] Error 2

Does anybody know how can I use -O0 flag? (I tried -Og flag but some
variables are still optimized out).

Thank you!

Chan Kim

 


[-- Attachment #1.2: Type: text/html, Size: 11558 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: error: impossible constraint in 'asm' when compiling kernel code with -O0 option
  2021-10-06  2:58 error: impossible constraint in 'asm' when compiling kernel code with -O0 option ckim
@ 2021-10-06  5:54 ` Jeffrey Walton
  2021-10-07 22:29 ` jim.cromie
  2022-01-19  9:47 ` Chan Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Walton @ 2021-10-06  5:54 UTC (permalink / raw)
  To: ckim; +Cc: kernelnewbies

On Tue, Oct 5, 2021 at 10:59 PM <ckim@etri.re.kr> wrote:
>
> In linux-5.4.21 code,
>
> To prevent some variables from being ‘optimized out’ during kernel code analysis using gdb, I added in drivers/iommu/Makefile,
> ...
> ./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'
>
>   120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
>...
>
> ./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro 'asm_volatile_goto'
>
>    38 |  asm_volatile_goto(
>
>       |  ^~~~~~~~~~~~~~~~~
>
> make[2]: *** [scripts/Makefile.build:266: drivers/iommu/io-pgtable-arm.o] Error 1
>
> make[1]: *** [scripts/Makefile.build:509: drivers/iommu] Error 2
>
> make: *** [Makefile:1652: drivers] Error 2
>
> Does anybody know how can I use -O0 flag? (I tried -Og flag but some variables are still optimized out).

Does goto(x) eventually paste x? I.e.,  ##x? Also see token pasting at
https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html.

Jeff

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: error: impossible constraint in 'asm' when compiling kernel code with -O0 option
  2021-10-06  2:58 error: impossible constraint in 'asm' when compiling kernel code with -O0 option ckim
  2021-10-06  5:54 ` Jeffrey Walton
@ 2021-10-07 22:29 ` jim.cromie
  2022-01-19  9:47 ` Chan Kim
  2 siblings, 0 replies; 4+ messages in thread
From: jim.cromie @ 2021-10-07 22:29 UTC (permalink / raw)
  To: ckim; +Cc: kernelnewbies

On Tue, Oct 5, 2021 at 9:00 PM <ckim@etri.re.kr> wrote:
>
> In linux-5.4.21 code,
>
> To prevent some variables from being ‘optimized out’ during kernel code analysis using gdb, I added in drivers/iommu/Makefile,
>
> (replacing -O2 flags to -O0 flags for some files,  I found http://www.joelfernandes.org/linux/2018/06/10/kernel-gdb.html )
>
> CFLAGS_REMOVE_arm-smmu.o := -O2
>
> CFLAGS_REMOVE_arm-smmu-impl.o := -O2
>
> CFLAGS_REMOVE_io-pgtable-arm-v7s.o := -O2
>
> CFLAGS_REMOVE_io-pgtable-arm.o := -O2
>
> CFLAGS_REMOVE_of_iommu.o := -O2
>
> CFLAGS_REMOVE_arm-smmu-v3.o := -O2
>
> CFLAGS_arm-smmu.o := -O0
>
> CFLAGS_arm-smmu-impl.o := -O0
>
> CFLAGS_io-pgtable-arm-v7s.o := -O0
>
> CFLAGS_io-pgtable-arm.o := -O0
>
> CFLAGS_of_iommu.o := -O0
>
> CFLAGS_arm-smmu-v3.o := -O0
>
> But when I do make ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- Image, I get
>
> CALL    scripts/checksyscalls.sh
>
>   CALL    scripts/atomic/check-atomics.sh
>
>   CHK     include/generated/compile.h
>
>   CC      drivers/iommu/io-pgtable-arm.o
>

try
make   drivers/iommu/io-pgtable-arm.i
it will show you intermediate output.

I did it on kernel/params.i  ( wrong config to run yours)

you will find the asm goto code therein

[jimc@samwise lm-sept]$ less +/jump_label kernel/params.i

# 53 "/home/jimc/projects/lx/wk-next/arch/x86/include/asm/jump_label.h"
static inline __attribute__((__gnu_inline__))
__attribute__((__unused__)) __attribute__((no_instrument_function))
__attribute__((__always_inline__)) boo
l arch_static_branch_jump(struct static_key * const key, const bool branch)
{
 do { asm goto("1:" "jmp %l[l_yes]\n\t" ".pushsection __jump_table,
\"aw\" \n\t" " " ".balign 8" " " "\n\t" ".long 1b - . \n\t" ".long
%l[l_yes] - . \n
\t" " " ".quad" " " "%c0 + %c1 - .\n\t" ".popsection \n\t" : : "i"
(key), "i" (branch) : : l_yes); asm (""); } while (0)


                                         ;

 return false;
l_yes:
 return true;
}

extern int arch_jump_entry_size(struct jump_entry *entry);
# 118 "/home/jimc/projects/lx/wk-next/include/linux/jump_label.h" 2

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* RE: error: impossible constraint in 'asm' when compiling kernel code with -O0 option
  2021-10-06  2:58 error: impossible constraint in 'asm' when compiling kernel code with -O0 option ckim
  2021-10-06  5:54 ` Jeffrey Walton
  2021-10-07 22:29 ` jim.cromie
@ 2022-01-19  9:47 ` Chan Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Chan Kim @ 2022-01-19  9:47 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 3446 bytes --]

Hi,

Today I found
https://stackoverflow.com/questions/5580140/is-there-a-way-to-tell-gcc-not-t
o-optimise-a-particular-piece-of-code. 

So for functions you want to debug with -O0 option,  place 

#pragma GCC push_options

#pragma GCC optimize ("O0")

In front of the function, and place

#pragma GCC pop_options

This sure works.

Chan

 

From: ckim@etri.re.kr <ckim@etri.re.kr> 
Sent: Wednesday, October 6, 2021 11:58 AM
To: kernelnewbies@kernelnewbies.org
Subject: error: impossible constraint in 'asm' when compiling kernel code
with -O0 option

 

In linux-5.4.21 code,

To prevent some variables from being 'optimized out' during kernel code
analysis using gdb, I added in drivers/iommu/Makefile,

(replacing -O2 flags to -O0 flags for some files,  I found
http://www.joelfernandes.org/linux/2018/06/10/kernel-gdb.html )

CFLAGS_REMOVE_arm-smmu.o := -O2

CFLAGS_REMOVE_arm-smmu-impl.o := -O2

CFLAGS_REMOVE_io-pgtable-arm-v7s.o := -O2

CFLAGS_REMOVE_io-pgtable-arm.o := -O2

CFLAGS_REMOVE_of_iommu.o := -O2

CFLAGS_REMOVE_arm-smmu-v3.o := -O2

CFLAGS_arm-smmu.o := -O0

CFLAGS_arm-smmu-impl.o := -O0

CFLAGS_io-pgtable-arm-v7s.o := -O0

CFLAGS_io-pgtable-arm.o := -O0

CFLAGS_of_iommu.o := -O0

CFLAGS_arm-smmu-v3.o := -O0

But when I do make ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- Image, I get

CALL    scripts/checksyscalls.sh

  CALL    scripts/atomic/check-atomics.sh

  CHK     include/generated/compile.h

  CC      drivers/iommu/io-pgtable-arm.o

In file included from ././include/linux/compiler_types.h:68,

                 from <command-line>:

./arch/arm64/include/asm/jump_label.h: In function
'system_uses_lse_atomics':

./include/linux/compiler-gcc.h:120:38: warning: asm operand 0 probably
doesn't match constraints

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

./include/linux/compiler-gcc.h:120:38: warning: asm operand 0 probably
doesn't match constraints

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

      |                                      ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

      |  ^~~~~~~~~~~~~~~~~

make[2]: *** [scripts/Makefile.build:266: drivers/iommu/io-pgtable-arm.o]
Error 1

make[1]: *** [scripts/Makefile.build:509: drivers/iommu] Error 2

make: *** [Makefile:1652: drivers] Error 2

Does anybody know how can I use -O0 flag? (I tried -Og flag but some
variables are still optimized out).

Thank you!

Chan Kim

 


[-- Attachment #1.2: Type: text/html, Size: 14359 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

end of thread, other threads:[~2022-01-19  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06  2:58 error: impossible constraint in 'asm' when compiling kernel code with -O0 option ckim
2021-10-06  5:54 ` Jeffrey Walton
2021-10-07 22:29 ` jim.cromie
2022-01-19  9:47 ` Chan Kim

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.