Skip to contentSkip to conversation

package/jpeg-turbo: force fPIC for shared libraries

PATCH New Romain Naour 3 participants 4 messages Feb 22, 2020 – Mar 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/jpeg-turbo: force fPIC for shared libraries

When BR2_SSP_ALL is set, there is a link issue due to missing -fPIC in CFLAGS. Set CMAKE_POSITION_INDEPENDENT_CODE=ON to add it.

This is a similar fix as for gtest package [1]

[1] https://git.buildroot.net/buildroot/commit/?id=2026621f3c60167aa8ba48e658be1b214d1347d7

Fixes:
http://autobuild.buildroot.net/results/e1f/e1f164cee16b037c0232fdda40fc16caf8f0c0af

Cc Murat Demirten <[email protected]>
---
 package/jpeg-turbo/jpeg-turbo.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/jpeg-turbo/jpeg-turbo.mk +10 -0
index 2767ce6de4..126b470630 100644
@@ -31,6 +31,16 @@ else
 JPEG_TURBO_CONF_OPTS += -DWITH_SIMD=OFF
 endif
 
+# Ensure that jpeg-turbo is compiled with -fPIC to allow linking the static
+# libraries with dynamically linked programs. This is not a requirement
+# for most architectures but is mandatory for ARM.
+# This allow to avoid link issues with BR2_SSP_ALL:
+# jsimd_none.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17'
+# can not be used when making a shared object; recompile with -fPIC
+ifeq ($(BR2_STATIC_LIBS),)
+JPEG_TURBO_CONF_OPTS += -DCMAKE_POSITION_INDEPENDENT_CODE=ON
+endif
+
 define JPEG_TURBO_REMOVE_USELESS_TOOLS
 	rm -f $(addprefix $(TARGET_DIR)/usr/bin/,cjpeg djpeg jpegtran rdjpgcom tjbench wrjpgcom)
 endef
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/1 package/jpeg-turbo: force fPIC for shared libraries

Romain, All,

On 2020-02-22 19:10 +0100, Romain Naour spake thusly:

Quoted 5 lines

When BR2_SSP_ALL is set, there is a link issue due to missing -fPIC in CFLAGS. Set CMAKE_POSITION_INDEPENDENT_CODE=ON to add it.

This is a similar fix as for gtest package [1]

Quoted 7 lines

[1] https://git.buildroot.net/buildroot/commit/?id=2026621f3c60167aa8ba48e658be1b214d1347d7

Fixes:
http://autobuild.buildroot.net/results/e1f/e1f164cee16b037c0232fdda40fc16caf8f0c0af

Cc Murat Demirten <[email protected]>

Applied to master, thanks.

However, one question below...

Quoted 11 lines
---
 package/jpeg-turbo/jpeg-turbo.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/jpeg-turbo/jpeg-turbo.mk +0 -0
index 2767ce6de4..126b470630 100644
@@ -31,6 +31,16 @@ else
 JPEG_TURBO_CONF_OPTS += -DWITH_SIMD=OFF
 endif

package/jpeg-turbo/jpeg-turbo.mk else · line 42

Quoted 10 lines
package/jpeg-turbo/jpeg-turbo.mk +9 -0
 
+# Ensure that jpeg-turbo is compiled with -fPIC to allow linking the static
+# libraries with dynamically linked programs. This is not a requirement
+# for most architectures but is mandatory for ARM.
+# This allow to avoid link issues with BR2_SSP_ALL:
+# jsimd_none.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17'
+# can not be used when making a shared object; recompile with -fPIC
+ifeq ($(BR2_STATIC_LIBS),)
+JPEG_TURBO_CONF_OPTS += -DCMAKE_POSITION_INDEPENDENT_CODE=ON
+endif

Should we not be doing that in the pkg-cmake infra instead?

Regards,
Yann E. MORIN.

Quoted 11 lines
package/jpeg-turbo/jpeg-turbo.mk +1 -0
+
 define JPEG_TURBO_REMOVE_USELESS_TOOLS
 	rm -f $(addprefix $(TARGET_DIR)/usr/bin/,cjpeg djpeg jpegtran rdjpgcom tjbench wrjpgcom)
 endef
Signature · 6 lines
2.24.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 package/jpeg-turbo: force fPIC for shared libraries

Hello Yann,

Le 22/02/2020 ? 19:31, Yann E. MORIN a ?crit?:

Quoted 32 lines

Romain, All,

On 2020-02-22 19:10 +0100, Romain Naour spake thusly:

Quoted 5 lines

When BR2_SSP_ALL is set, there is a link issue due to missing -fPIC in CFLAGS. Set CMAKE_POSITION_INDEPENDENT_CODE=ON to add it.

This is a similar fix as for gtest package [1]

Quoted 7 lines

[1] https://git.buildroot.net/buildroot/commit/?id=2026621f3c60167aa8ba48e658be1b214d1347d7

Fixes:
http://autobuild.buildroot.net/results/e1f/e1f164cee16b037c0232fdda40fc16caf8f0c0af

Cc Murat Demirten <[email protected]>

Applied to master, thanks.

However, one question below...

Quoted 12 lines
---
 package/jpeg-turbo/jpeg-turbo.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)
package/jpeg-turbo/jpeg-turbo.mk +0 -0
index 2767ce6de4..126b470630 100644
@@ -31,6 +31,16 @@ else
 JPEG_TURBO_CONF_OPTS += -DWITH_SIMD=OFF
 endif
 
Quoted 11 lines

package/jpeg-turbo/jpeg-turbo.mk else · line 42

Quoted 9 lines
package/jpeg-turbo/jpeg-turbo.mk +9 -0
+# Ensure that jpeg-turbo is compiled with -fPIC to allow linking the static
+# libraries with dynamically linked programs. This is not a requirement
+# for most architectures but is mandatory for ARM.
+# This allow to avoid link issues with BR2_SSP_ALL:
+# jsimd_none.c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17'
+# can not be used when making a shared object; recompile with -fPIC
+ifeq ($(BR2_STATIC_LIBS),)
+JPEG_TURBO_CONF_OPTS += -DCMAKE_POSITION_INDEPENDENT_CODE=ON
+endif

Should we not be doing that in the pkg-cmake infra instead?

For now we only do this only for gtest package (and now this one). But indeed, this could be done in pkg-cmake.

Best regards,
Romain

Quoted 16 lines

Regards,
Yann E. MORIN.

Quoted 11 lines
package/jpeg-turbo/jpeg-turbo.mk +1 -0
+
 define JPEG_TURBO_REMOVE_USELESS_TOOLS
 	rm -f $(addprefix $(TARGET_DIR)/usr/bin/,cjpeg djpeg jpegtran rdjpgcom tjbench wrjpgcom)
 endef
Signature · 6 lines
2.24.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

PATCH 1/1 package/jpeg-turbo: force fPIC for shared libraries

In reply to Romain Naour
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Romain" == Romain Naour <[email protected]> writes:

When BR2_SSP_ALL is set, there is a link issue due to missing -fPIC in CFLAGS. Set CMAKE_POSITION_INDEPENDENT_CODE=ON to add it.

This is a similar fix as for gtest package [1]

Quoted 7 lines

[1] https://git.buildroot.net/buildroot/commit/?id=2026621f3c60167aa8ba48e658be1b214d1347d7

Fixes:
http://autobuild.buildroot.net/results/e1f/e1f164cee16b037c0232fdda40fc16caf8f0c0af

Cc Murat Demirten <[email protected]>

Committed to 2019.02.x and 2019.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard