lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
* [lttng-dev] with -Og option, lttng-ust compile failed on 32bit arm
@ 2021-09-30  3:47 Changqing Li via lttng-dev
  2021-09-30 13:14 ` Mathieu Desnoyers via lttng-dev
  0 siblings, 1 reply; 3+ messages in thread
From: Changqing Li via lttng-dev @ 2021-09-30  3:47 UTC (permalink / raw)
  To: lttng-dev; +Cc: Changqing Li


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

Hi,

The problem happened after upgrade to lttng-ust 2.13.0.  2.12.0 don't 
have this issue.

liburcu version: 0.13.0

gcc: 11.2.0

This is my reproduce steps, it is cross compile enviroment based on 
yocto project.

 1. git clone git://git.yoctoproject.org/poky
 2. . oe-init-build-env
 3. echo "MACHINE='qemuarm'" >> conf/local.conf
 4. echo "DEBUG_BUILD='1'" >> conf/local.conf
 5. bitbake lttng-ust

compile failed with error:

| 
/work/cortexa15t2hf-neon-poky-linux-gnueabi/lttng-ust/2_2.13.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/ld: 
../../../src/lib/lttng-ust/.libs/liblttng-ust.so: undefined reference to 
`_uatomic_link_error'
| collect2: error: ld returned 1 exit status
| Makefile:399: recipe for target 'test_ust_error' failed

checked with "nm ../../../src/lib/lttng-ust/.libs/liblttng-ust.so" | 
grep atomic, we can see 'U _uatomic_link_error',  but since -Og

is used,  liburcu don't define this function.

[snip]
#if !defined __OPTIMIZE__  || defined UATOMIC_NO_LINK_ERROR
static inline __attribute__((always_inline, noreturn))
void _uatomic_link_error(void)
{
#ifdef ILLEGAL_INSTR
         /*
          * generate an illegal instruction. Cannot catch this with
          * linker tricks when optimizations are disabled.
          */
         __asm__ __volatile__(ILLEGAL_INSTR);
#else
         __builtin_trap();
#endif
}
#else /* #if !defined __OPTIMIZE__  || defined UATOMIC_NO_LINK_ERROR */
extern void _uatomic_link_error(void);
#endif /* #else #if !defined __OPTIMIZE__  || defined 
UATOMIC_NO_LINK_ERROR */

[snip]

we cannot see 'U _uatomic_link_error' in following conditions, so 
compile successed:

1.  without -Og(using -O2),  + 32bit arm

2. -Og + 64bit arm

3. -Og + x86/x86-64


Do you have any idea about how to fix this? I don't understand why only 
"-Og + 32bit arm" will call function _uatomic_link_error.

Thanks

//Changqing


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

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

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

* Re: [lttng-dev] with -Og option, lttng-ust compile failed on 32bit arm
  2021-09-30  3:47 [lttng-dev] with -Og option, lttng-ust compile failed on 32bit arm Changqing Li via lttng-dev
@ 2021-09-30 13:14 ` Mathieu Desnoyers via lttng-dev
  2021-10-08  8:12   ` Changqing Li via lttng-dev
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Desnoyers via lttng-dev @ 2021-09-30 13:14 UTC (permalink / raw)
  To: Changqing Li; +Cc: lttng-dev


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

----- On Sep 29, 2021, at 11:47 PM, lttng-dev <lttng-dev@lists.lttng.org> wrote: 

> Hi,

> The problem happened after upgrade to lttng-ust 2.13.0. 2.12.0 don't have this
> issue.

> liburcu version: 0.13.0

> gcc: 11.2.0

> This is my reproduce steps, it is cross compile enviroment based on yocto
> project.

>     1. git clone git://git.yoctoproject.org/poky
>     2. . oe-init-build-env
>     3. echo "MACHINE='qemuarm'" >> conf/local.conf
>     4. echo "DEBUG_BUILD='1'" >> conf/local.conf
>     5. bitbake lttng-ust

> compile failed with error:

>| /work/cortexa15t2hf-neon-poky-linux-gnueabi/lttng-ust/2_2.13.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/ld:
>| ../../../src/lib/lttng-ust/.libs/liblttng-ust.so: undefined reference to
> | `_uatomic_link_error'
> | collect2: error: ld returned 1 exit status
> | Makefile:399: recipe for target 'test_ust_error' failed

> checked with "nm ../../../src/lib/lttng-ust/.libs/liblttng-ust.so" | grep
> atomic, we can see 'U _uatomic_link_error', but since -Og

> is used, liburcu don't define this function.

> [snip]
> #if !defined __OPTIMIZE__ || defined UATOMIC_NO_LINK_ERROR
> static inline __attribute__((always_inline, noreturn))
> void _uatomic_link_error(void)
> {
> #ifdef ILLEGAL_INSTR
> /*
> * generate an illegal instruction. Cannot catch this with
> * linker tricks when optimizations are disabled.
> */
> __asm__ __volatile__(ILLEGAL_INSTR);
> #else
> __builtin_trap();
> #endif
> }
> #else /* #if !defined __OPTIMIZE__ || defined UATOMIC_NO_LINK_ERROR */
> extern void _uatomic_link_error(void);
> #endif /* #else #if !defined __OPTIMIZE__ || defined UATOMIC_NO_LINK_ERROR */

> [snip]

> we cannot see 'U _uatomic_link_error' in following conditions, so compile
> successed:

> 1. without -Og(using -O2), + 32bit arm

> 2. -Og + 64bit arm

> 3. -Og + x86/x86-64

> Do you have any idea about how to fix this? I don't understand why only "-Og +
> 32bit arm" will call function _uatomic_link_error.
I suspect it depends on which optimizations are being enabled at -Og on each architecture. 
The "_uatomic_link_error()" trick indeed depends on the compiler optimizing away 
unreachable calls. 

If you really intend on using "-Og" on arm32, trying building with "-DUATOMIC_NO_LINK_ERROR". 
It should take care of making sure to generate an illegal instruction rather than rely on the linker 
error. 

Thanks, 

Mathieu 

> Thanks

> //Changqing

> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 

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

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

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

* Re: [lttng-dev] with -Og option, lttng-ust compile failed on 32bit arm
  2021-09-30 13:14 ` Mathieu Desnoyers via lttng-dev
@ 2021-10-08  8:12   ` Changqing Li via lttng-dev
  0 siblings, 0 replies; 3+ messages in thread
From: Changqing Li via lttng-dev @ 2021-10-08  8:12 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev


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


On 9/30/21 9:14 PM, Mathieu Desnoyers wrote:
>
> **[Please note: This e-mail is from an EXTERNAL e-mail address]
>
> ----- On Sep 29, 2021, at 11:47 PM, lttng-dev 
> <lttng-dev@lists.lttng.org> wrote:
>
>     Hi,
>
>     The problem happened after upgrade to lttng-ust 2.13.0.  2.12.0
>     don't have this issue.
>
>     liburcu version: 0.13.0
>
>     gcc: 11.2.0
>
>     This is my reproduce steps, it is cross compile enviroment based
>     on yocto project.
>
>      1. git clone git://git.yoctoproject.org/poky
>      2. . oe-init-build-env
>      3. echo "MACHINE='qemuarm'" >> conf/local.conf
>      4. echo "DEBUG_BUILD='1'" >> conf/local.conf
>      5. bitbake lttng-ust
>
>     compile failed with error:
>
>     |
>     /work/cortexa15t2hf-neon-poky-linux-gnueabi/lttng-ust/2_2.13.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.2.0/ld:
>     ../../../src/lib/lttng-ust/.libs/liblttng-ust.so
>     <https://urldefense.com/v3/__http://liblttng-ust.so__;!!AjveYdw8EvQ!LLTouw-mBEBAY8hObF75ydNA3D3KMc0Hla12A4D4cQ-hm-F5lidnggb4zDVbAwolB77-gw$>:
>     undefined reference to `_uatomic_link_error'
>     | collect2: error: ld returned 1 exit status
>     | Makefile:399: recipe for target 'test_ust_error' failed
>
>     checked with "nm ../../../src/lib/lttng-ust/.libs/liblttng-ust.so
>     <https://urldefense.com/v3/__http://liblttng-ust.so__;!!AjveYdw8EvQ!LLTouw-mBEBAY8hObF75ydNA3D3KMc0Hla12A4D4cQ-hm-F5lidnggb4zDVbAwolB77-gw$>"
>     | grep atomic,   we can see 'U _uatomic_link_error',  but since -Og
>
>     is used,  liburcu don't define this function.
>
>     [snip]
>     #if !defined __OPTIMIZE__  || defined UATOMIC_NO_LINK_ERROR
>     static inline __attribute__((always_inline, noreturn))
>     void _uatomic_link_error(void)
>     {
>     #ifdef ILLEGAL_INSTR
>             /*
>              * generate an illegal instruction. Cannot catch this with
>              * linker tricks when optimizations are disabled.
>              */
>             __asm__ __volatile__(ILLEGAL_INSTR);
>     #else
>             __builtin_trap();
>     #endif
>     }
>     #else /* #if !defined __OPTIMIZE__  || defined
>     UATOMIC_NO_LINK_ERROR */
>     extern void _uatomic_link_error(void);
>     #endif /* #else #if !defined __OPTIMIZE__  || defined
>     UATOMIC_NO_LINK_ERROR */
>
>     [snip]
>
>     we cannot see 'U _uatomic_link_error' in following conditions, so
>     compile successed:
>
>     1.  without -Og(using -O2),  + 32bit arm
>
>     2. -Og + 64bit arm
>
>     3. -Og + x86/x86-64
>
>
>     Do you have any idea about how to fix this? I don't understand why
>     only "-Og + 32bit arm" will call function _uatomic_link_error.
>
>
> I suspect it depends on which optimizations are being enabled at -Og 
> on each architecture.
> The "_uatomic_link_error()" trick indeed depends on the compiler 
> optimizing away
> unreachable calls.
>
> If you really intend on using "-Og" on arm32, trying building with 
> "-DUATOMIC_NO_LINK_ERROR".
> It should take care of making sure to generate an illegal instruction 
> rather than rely on the linker
> error.
>
> Thanks,
>
> Mathieu

Thanks.  I have tried with "-DUATOMIC_NO_LINK_ERROR".  With this,  it 
can compile successfully.

Changqing

>
>     Thanks
>
>     //Changqing
>
>
>     _______________________________________________
>     lttng-dev mailing list
>     lttng-dev@lists.lttng.org
>     https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>     <https://urldefense.com/v3/__https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev__;!!AjveYdw8EvQ!LLTouw-mBEBAY8hObF75ydNA3D3KMc0Hla12A4D4cQ-hm-F5lidnggb4zDVbAwqteQD9FQ$>
>
>
> -- 
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com 
> <https://urldefense.com/v3/__http://www.efficios.com__;!!AjveYdw8EvQ!LLTouw-mBEBAY8hObF75ydNA3D3KMc0Hla12A4D4cQ-hm-F5lidnggb4zDVbAwo9O85jiQ$>

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

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

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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

end of thread, other threads:[~2021-10-08  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30  3:47 [lttng-dev] with -Og option, lttng-ust compile failed on 32bit arm Changqing Li via lttng-dev
2021-09-30 13:14 ` Mathieu Desnoyers via lttng-dev
2021-10-08  8:12   ` Changqing Li via lttng-dev

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).