2020-12-21 18:45:30

by Marius Bakke

[permalink] [raw]
Subject: [PATCH v2] sbc_primitives: Fix build on non-x86.

From: Marius Bakke <[email protected]>

Don't call __builtin_cpu_init unless targeting i386 or x86_64.
Otherwise we get an error at link time:

CC sbc/sbc_primitives.lo
sbc/sbc_primitives.c: In function ‘sbc_init_primitives_x86’:
sbc/sbc_primitives.c:596:2: warning: implicit declaration of function ‘__builtin_cpu_init’; did you mean ‘__builtin_irint’? [-Wimplicit-function-declaration]
[...]
CCLD src/sbcdec
ld: sbc/.libs/libsbc-private.a(sbc_primitives.o): in function `sbc_init_primitives':
sbc_primitives.c:(.text+0x3a30): undefined reference to `__builtin_cpu_init'
---
sbc/sbc_primitives.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c
index 97a75be..d8e166a 100644
--- a/sbc/sbc_primitives.c
+++ b/sbc/sbc_primitives.c
@@ -593,7 +593,9 @@ static int sbc_calc_scalefactors_j(

static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
{
+#if defined(__x86_64__) || defined(__i386__)
__builtin_cpu_init();
+#endif

#ifdef SBC_BUILD_WITH_MMX_SUPPORT
if (__builtin_cpu_supports("mmx"))
--
2.29.2


2020-12-22 01:59:53

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH v2] sbc_primitives: Fix build on non-x86.

Hi Marius,

On Mon, Dec 21, 2020 at 10:45 AM <[email protected]> wrote:
>
> From: Marius Bakke <[email protected]>
>
> Don't call __builtin_cpu_init unless targeting i386 or x86_64.
> Otherwise we get an error at link time:
>
> CC sbc/sbc_primitives.lo
> sbc/sbc_primitives.c: In function ‘sbc_init_primitives_x86’:
> sbc/sbc_primitives.c:596:2: warning: implicit declaration of function ‘__builtin_cpu_init’; did you mean ‘__builtin_irint’? [-Wimplicit-function-declaration]
> [...]
> CCLD src/sbcdec
> ld: sbc/.libs/libsbc-private.a(sbc_primitives.o): in function `sbc_init_primitives':
> sbc_primitives.c:(.text+0x3a30): undefined reference to `__builtin_cpu_init'
> ---
> sbc/sbc_primitives.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c
> index 97a75be..d8e166a 100644
> --- a/sbc/sbc_primitives.c
> +++ b/sbc/sbc_primitives.c
> @@ -593,7 +593,9 @@ static int sbc_calc_scalefactors_j(
>
> static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
> {
> +#if defined(__x86_64__) || defined(__i386__)
> __builtin_cpu_init();

I would probably have the entire function under the #if here.

> +#endif
>
> #ifdef SBC_BUILD_WITH_MMX_SUPPORT
> if (__builtin_cpu_supports("mmx"))
> --
> 2.29.2
>


--
Luiz Augusto von Dentz

2020-12-22 11:07:11

by Marius Bakke

[permalink] [raw]
Subject: [PATCH v3] sbc_primitives: Fix build on non-x86.

From: Marius Bakke <[email protected]>

Don't call __builtin_cpu_init unless targeting i386 or x86_64.
Otherwise we get an error at link time:

CC sbc/sbc_primitives.lo
sbc/sbc_primitives.c: In function ‘sbc_init_primitives_x86’:
sbc/sbc_primitives.c:596:2: warning: implicit declaration of function ‘__builtin_cpu_init’; did you mean ‘__builtin_irint’? [-Wimplicit-function-declaration]
[...]
CCLD src/sbcdec
ld: sbc/.libs/libsbc-private.a(sbc_primitives.o): in function `sbc_init_primitives':
sbc_primitives.c:(.text+0x3a30): undefined reference to `__builtin_cpu_init'
---
sbc/sbc_primitives.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c
index 97a75be..09c214a 100644
--- a/sbc/sbc_primitives.c
+++ b/sbc/sbc_primitives.c
@@ -593,6 +593,7 @@ static int sbc_calc_scalefactors_j(

static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
{
+#if defined(__x86_64__) || defined(__i386__)
__builtin_cpu_init();

#ifdef SBC_BUILD_WITH_MMX_SUPPORT
@@ -604,6 +605,7 @@ static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
if (__builtin_cpu_supports("sse4.2"))
sbc_init_primitives_sse(state);
#endif
+#endif
}

/*
--
2.29.2

2020-12-22 11:08:55

by Marius Bakke

[permalink] [raw]
Subject: Re: [PATCH v2] sbc_primitives: Fix build on non-x86.

Luiz Augusto von Dentz <[email protected]> skriver:

> Hi Marius,
>
> On Mon, Dec 21, 2020 at 10:45 AM <[email protected]> wrote:
>>
>> From: Marius Bakke <[email protected]>
>>
>> Don't call __builtin_cpu_init unless targeting i386 or x86_64.
>> Otherwise we get an error at link time:
>>
>> CC sbc/sbc_primitives.lo
>> sbc/sbc_primitives.c: In function ‘sbc_init_primitives_x86’:
>> sbc/sbc_primitives.c:596:2: warning: implicit declaration of function ‘__builtin_cpu_init’; did you mean ‘__builtin_irint’? [-Wimplicit-function-declaration]
>> [...]
>> CCLD src/sbcdec
>> ld: sbc/.libs/libsbc-private.a(sbc_primitives.o): in function `sbc_init_primitives':
>> sbc_primitives.c:(.text+0x3a30): undefined reference to `__builtin_cpu_init'
>> ---
>> sbc/sbc_primitives.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c
>> index 97a75be..d8e166a 100644
>> --- a/sbc/sbc_primitives.c
>> +++ b/sbc/sbc_primitives.c
>> @@ -593,7 +593,9 @@ static int sbc_calc_scalefactors_j(
>>
>> static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
>> {
>> +#if defined(__x86_64__) || defined(__i386__)
>> __builtin_cpu_init();
>
> I would probably have the entire function under the #if here.

That makes sense; v3 sent!

Thanks,
Marius


Attachments:
signature.asc (517.00 B)

2020-12-22 21:19:35

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH v3] sbc_primitives: Fix build on non-x86.

Hi Marius,

On Tue, Dec 22, 2020 at 3:07 AM Marius Bakke <[email protected]> wrote:
>
> From: Marius Bakke <[email protected]>
>
> Don't call __builtin_cpu_init unless targeting i386 or x86_64.
> Otherwise we get an error at link time:
>
> CC sbc/sbc_primitives.lo
> sbc/sbc_primitives.c: In function ‘sbc_init_primitives_x86’:
> sbc/sbc_primitives.c:596:2: warning: implicit declaration of function ‘__builtin_cpu_init’; did you mean ‘__builtin_irint’? [-Wimplicit-function-declaration]
> [...]
> CCLD src/sbcdec
> ld: sbc/.libs/libsbc-private.a(sbc_primitives.o): in function `sbc_init_primitives':
> sbc_primitives.c:(.text+0x3a30): undefined reference to `__builtin_cpu_init'
> ---
> sbc/sbc_primitives.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c
> index 97a75be..09c214a 100644
> --- a/sbc/sbc_primitives.c
> +++ b/sbc/sbc_primitives.c
> @@ -593,6 +593,7 @@ static int sbc_calc_scalefactors_j(
>
> static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
> {
> +#if defined(__x86_64__) || defined(__i386__)
> __builtin_cpu_init();
>
> #ifdef SBC_BUILD_WITH_MMX_SUPPORT
> @@ -604,6 +605,7 @@ static void sbc_init_primitives_x86(struct sbc_encoder_state *state)
> if (__builtin_cpu_supports("sse4.2"))
> sbc_init_primitives_sse(state);
> #endif
> +#endif
> }
>
> /*
> --
> 2.29.2

Applied, thanks.

--
Luiz Augusto von Dentz