2015-07-05 08:27:04

by Chen Gang

[permalink] [raw]
Subject: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

For upstream cris toolchain (gcc is 6.0, gas and ld are 2.25.51), they
can not recognize the static variable between embedded global asm code
and local C code.

So let it as extern variable to let the related code pass building, it
is harmless for real world using (although it is not quite well for
coding styles).

The related error (with allmodconfig under cris for next-20150702):

arch/cris/arch-v10/kernel/built-in.o: In function `kgdb_handle_breakpoint':
(.text+0x2aca): undefined reference to `is_dyn_brkp'
arch/cris/arch-v10/kernel/built-in.o: In function `is_static':
kgdb.c:(.text+0x2ada): undefined reference to `is_dyn_brkp'


Signed-off-by: Chen Gang <[email protected]>
---
arch/cris/arch-v10/kernel/kgdb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index 22d846b..3553406 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -351,7 +351,7 @@ char internal_stack[INTERNAL_STACK_SIZE];
breakpoint to be handled. A static breakpoint uses the content of register
BRP as it is whereas a dynamic breakpoint requires subtraction with 2
in order to execute the instruction. The first breakpoint is static. */
-static unsigned char is_dyn_brkp = 0;
+unsigned char is_dyn_brkp;

/********************************* String library ****************************/
/* Single-step over library functions creates trap loops. */
--
1.9.3


2015-07-05 18:25:29

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
> For upstream cris toolchain (gcc is 6.0

typo?


Attachments:
(No filename) (848.00 B)

2015-07-06 07:50:52

by Chen Gang

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On 07/06/2015 02:25 AM, [email protected] wrote:
> On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
>> For upstream cris toolchain (gcc is 6.0
>
> typo?
>

Do you mean "toolchain" -> "tool chain"?


Thanks.
--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

2015-07-06 10:31:40

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On Mon, 06 Jul 2015 15:49:20 +0800, Chen Gang said:
> On 07/06/2015 02:25 AM, [email protected] wrote:
> > On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
> >> For upstream cris toolchain (gcc is 6.0
> >
> > typo?
> >
>
> Do you mean "toolchain" -> "tool chain"?

No, I was wondering where a gcc 6.0 managed to escape when 5.1 just got
released about 2 weeks ago....


Attachments:
(No filename) (848.00 B)

2015-07-06 22:27:30

by Chen Gang

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On 7/6/15 18:31, [email protected] wrote:
> On Mon, 06 Jul 2015 15:49:20 +0800, Chen Gang said:
>> On 07/06/2015 02:25 AM, [email protected] wrote:
>>> On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
>>>> For upstream cris toolchain (gcc is 6.0
>>>
>>> typo?
>>>
>>
>> Do you mean "toolchain" -> "tool chain"?
>
> No, I was wondering where a gcc 6.0 managed to escape when 5.1 just got
> released about 2 weeks ago....
>

OK, thanks. At present, gcc 6.0 is the latest in master branch.

After check fedora released toolchain (gcc 4.9.1, binutils 2.25), it has
no issue (support static variable in our case). So this patch can be
dropped, and I shall try:

- Use the same configuration parameters of fedora released toolchain to
build the upstream latest cross toolchain again, and try.

- If it still has issue (not support static variable), I shall try to
fix it.


Thanks.
--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

2015-07-09 01:26:01

by Chen Gang

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On 07/07/2015 06:28 AM, Chen Gang wrote:
> On 7/6/15 18:31, [email protected] wrote:
>> On Mon, 06 Jul 2015 15:49:20 +0800, Chen Gang said:
>>> On 07/06/2015 02:25 AM, [email protected] wrote:
>>>> On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
>>>>> For upstream cris toolchain (gcc is 6.0
>>>>
>>>> typo?
>>>>
>>>
>>> Do you mean "toolchain" -> "tool chain"?
>>
>> No, I was wondering where a gcc 6.0 managed to escape when 5.1 just got
>> released about 2 weeks ago....
>>
>

Oh, sorry, gcc 5.1 has the same issue, and at present I guess:

- The new gcc have additional optimization for the static variables. It
should notice about the related c code when optimizing, but gcc has
no idea about assembly code (it should passes them to gas, directly).

- If one want gcc skip the related optimization, it can use 'volatile'
for it (the static variable which may be used by both c code and
assembly code in one file).

- So for me, we need add 'volatile' to the related static variable, we
do not want to disable this optimization only because of this issue.

Welcome any additional ideas, suggestions and completions.

> OK, thanks. At present, gcc 6.0 is the latest in master branch.
>
> After check fedora released toolchain (gcc 4.9.1, binutils 2.25), it has
> no issue (support static variable in our case). So this patch can be
> dropped, and I shall try:
>
> - Use the same configuration parameters of fedora released toolchain to
> build the upstream latest cross toolchain again, and try.
>
> - If it still has issue (not support static variable), I shall try to
> fix it.
>
>
> Thanks.
>

--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

2015-07-09 01:27:06

by Chen Gang

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On 07/07/2015 06:28 AM, Chen Gang wrote:
> On 7/6/15 18:31, [email protected] wrote:
>> On Mon, 06 Jul 2015 15:49:20 +0800, Chen Gang said:
>>> On 07/06/2015 02:25 AM, [email protected] wrote:
>>>> On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
>>>>> For upstream cris toolchain (gcc is 6.0
>>>>
>>>> typo?
>>>>
>>>
>>> Do you mean "toolchain" -> "tool chain"?
>>
>> No, I was wondering where a gcc 6.0 managed to escape when 5.1 just got
>> released about 2 weeks ago....
>>
>

Oh, sorry, gcc 5.1 is the same, and at present, for me:

- The new gcc have additional optimization for the static variables. It
should notice about the related c code when optimizing, but gcc has
no idea about assembly code (it should passes them to gas, directly).

- If one want gcc skip the related optimization, it can use 'volatile'
for it (the static variable which may be used by both c code and
assembly code in one file).

- So I guess, we need add 'volatile' to the related static variable, we
do not want to disable this optimization only because of this issue.

Welcome any additional ideas, suggestions and completions.

> OK, thanks. At present, gcc 6.0 is the latest in master branch.
>
> After check fedora released toolchain (gcc 4.9.1, binutils 2.25), it has
> no issue (support static variable in our case). So this patch can be
> dropped, and I shall try:
>
> - Use the same configuration parameters of fedora released toolchain to
> build the upstream latest cross toolchain again, and try.
>
> - If it still has issue (not support static variable), I shall try to
> fix it.
>
>
> Thanks.
>

--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2015-07-09 22:44:58

by Chen Gang

[permalink] [raw]
Subject: Re: [PATCH] cris: arch-v10: kernel: kgdb: let is_dyn_brkp as extern variable

On 7/9/15 09:26, gchen gchen wrote:
> On 07/07/2015 06:28 AM, Chen Gang wrote:
>> On 7/6/15 18:31, [email protected] wrote:
>>> On Mon, 06 Jul 2015 15:49:20 +0800, Chen Gang said:
>>>> On 07/06/2015 02:25 AM, [email protected] wrote:
>>>>> On Sun, 05 Jul 2015 06:07:54 +0800, Chen Gang said:
>>>>>> For upstream cris toolchain (gcc is 6.0
>>>>>
>>>>> typo?
>>>>>
>>>>
>>>> Do you mean "toolchain" -> "tool chain"?
>>>
>>> No, I was wondering where a gcc 6.0 managed to escape when 5.1 just got
>>> released about 2 weeks ago....
>>>
>>

gcc 5.1 with the same fedora configuration also causes the same issue:

[root@localhost gcc]# /upstream/release-cris-fedora-conf/bin/cris-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/upstream/release-cris-fedora-conf/bin/cris-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/upstream/release-cris-fedora-conf/libexec/gcc/cris-linux-gnu/5.1.0/lto-wrapper
Target: cris-linux-gnu
Configured with: ../gcc/configure --disable-nls --prefix=/upstream/release-cris-fedora-conf --disable-decimal-float --disable-dependency-tracking --disable-gold --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-nls --disable-plugin --disable-shared --disable-silent-rules --disable-sjlj-exceptions --disable-threads --enable-gnu-unique-object --enable-initfini-array --enable-languages=c --enable-linker-build-id --enable-nls --enable-obsolete --enable-targets=all --target=cris-linux-gnu --with-linker-hash-style=gnu --with-system-libunwind --with-system-zlib --without-headers
Thread model: single
gcc version 5.1.0 (GCC)

So we need add 'volatile' for the static global variable which is used
between C code and assembly code. I shall send patch v2 for it within
this week (2015-07-12).

Welcome any members ideas, suggestions, and completions.

Thanks.

>
> Oh, sorry, gcc 5.1 is the same, and at present, for me:
>
> - The new gcc have additional optimization for the static variables. It
> should notice about the related c code when optimizing, but gcc has
> no idea about assembly code (it should passes them to gas, directly).
>
> - If one want gcc skip the related optimization, it can use 'volatile'
> for it (the static variable which may be used by both c code and
> assembly code in one file).
>
> - So I guess, we need add 'volatile' to the related static variable, we
> do not want to disable this optimization only because of this issue.
>
> Welcome any additional ideas, suggestions and completions.
>
>> OK, thanks. At present, gcc 6.0 is the latest in master branch.
>>
>> After check fedora released toolchain (gcc 4.9.1, binutils 2.25), it has
>> no issue (support static variable in our case). So this patch can be
>> dropped, and I shall try:
>>
>> - Use the same configuration parameters of fedora released toolchain to
>> build the upstream latest cross toolchain again, and try.
>>
>> - If it still has issue (not support static variable), I shall try to
>> fix it.
>>
>>
>> Thanks.
>>
>
> --
> Chen Gang
>
> Open, share, and attitude like air, water, and life which God blessed
>
>

--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed