Bug 215974 - [PATCH] audio/liba52: armv6 build requires -fPIC
Summary: [PATCH] audio/liba52: armv6 build requires -fPIC
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-multimedia (Nobody)
Keywords: patch
Depends on:
Blocks: 216816
  Show dependency treegraph
Reported: 2017-01-11 16:29 UTC by Michal Meloun
Modified: 2017-09-28 19:43 UTC (History)
4 users (show)

See Also:

proposed patch (250 bytes, patch)
2017-01-11 16:29 UTC, Michal Meloun
no flags Details | Diff
new version (311 bytes, patch)
2017-09-06 10:51 UTC, Michal Meloun
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Meloun freebsd_committer 2017-01-11 16:29:25 UTC
Created attachment 178757 [details]
proposed patch

armv6 is similar to aarch64 in that it requires -fPIC when building shared libs.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2017-02-03 13:19:59 UTC
As of 20170124 it seems to build on the cluster.  Is this patch still needed for native builds?
Comment 2 Michal Meloun freebsd_committer 2017-02-03 15:06:01 UTC
Yes, it's still needed.
By ARM EABI, shared library must be compiled with -fPIC.
(In short, standard ARM object file may contain relocations which cannot be resolved by runtime linker, like R_ARM_MOVW_*, R_ARM_MOVT_*.)

The port build fails if you have specified any 'higher' CPU type. 
With -mcpu=cortex-a15, the build fails with:
(and I'm sorry, I did not realize that -mcpu is necessary for the exhibition of this problem) 

/bin/sh ../libtool --mode=link cc  -pipe  -munaligned-access -mcpu=cortex-a15
  -fno-builtin-sin -fno-builtin-cos  -fno-strict-aliasing -O -pipe -O2
  -munaligned-access  -fomit-frame-pointer  -prefer-non-pic  -o liba52.la
  -rpath /usr/local/lib -no-undefined bitstream.lo imdct.lo bit_allocate.lo
   parse.lo downmix.lo -lm

rm -fr .libs/liba52.la .libs/liba52.* .libs/liba52.*

cc -shared  bitstream.lo imdct.lo bit_allocate.lo parse.lo downmix.lo 
  -lm  -Wl,-soname -Wl,liba52.so.0 -o .libs/liba52.so.0.0.0

/usr/bin/ld: imdct.lo(.text+0x90c): 
  unresolvable R_ARM_MOVW_ABS_NC relocation against symbol `__stderrp@@FBSD_1.0'

/usr/bin/ld: final link failed: Nonrepresentable section on output
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2017-02-17 14:41:48 UTC
This may not be the right commit; see
https://lists.freebsd.org/pipermail/svn-ports-all/2017-February/144857.html .
Comment 4 Sylvain Garrigues 2017-09-06 10:14:55 UTC
This bug is still valid now (6 months later after initial report) and the attached patch did fix the build. 

Shall we commit it?
Comment 5 Michal Meloun freebsd_committer 2017-09-06 10:51:25 UTC
Created attachment 186114 [details]
new version

Yes, it is still valid. But due to upcoming armv7 architecture (see PR221894 ) I think that is better to also add it now.
Comment 6 Mark Millard 2017-09-25 08:10:33 UTC
(In reply to Michal Meloun from comment #5)

With this patch applied audio/liba52 built
just fine.

(I had reported my example of the issue to the
lists and someone pointed me to this bugzilla

No longer does this bugzilla need to say
"Affects Only Me" since I've another example.
(But I do not have permission to change that
Comment 7 Michal Meloun freebsd_committer 2017-09-27 13:53:57 UTC
Ping. Can you, please, commit it?  Proposed fix is nop for all but armv6/7 and this bug blocks many qt5-* ports.
Comment 8 Mark Millard 2017-09-27 19:44:35 UTC
(In reply to Michal Meloun from comment #7)

I'm not sure that anyone with a committer
status is significantly involved with this
bugzilla yet. The "Assignee" is a generic
multimedia@ one.

Also: as far as I can tell a more proper
fix is more likely to be something like:


instead of listing each architecture separately.

(This presumes that the software ported does not
have its own means requesting such handling. If
it does then it might be preferred to use that
technique of requesting it instead.)

I think that is what comment #3 was about.
Comment 9 Jan Beich freebsd_committer 2017-09-27 20:35:40 UTC
>  CFLAGS_aarch64=	-fPIC
>  CFLAGS_amd64=	-fPIC
> +CFLAGS_armv6=	-fPIC
> +CFLAGS_armv7=	-fPIC
>  CFLAGS_powerpc=	-fPIC

Why not drop -prefer-non-pic instead? Maybe libtool maintainer has a clue.

Comment 10 Tijl Coosemans freebsd_committer 2017-09-28 09:32:44 UTC
(In reply to Jan Beich from comment #9)
Yes, those Linux patches are correct.  You can remove CFLAGS_<arch>+=-fPIC from the port Makefile then.
Comment 11 commit-hook freebsd_committer 2017-09-28 19:33:24 UTC
A commit references this bug:

Author: jbeich
Date: Thu Sep 28 19:32:49 UTC 2017
New revision: 450863
URL: https://svnweb.freebsd.org/changeset/ports/450863

  audio/liba52: build PIC objects on all architectures

  PR:		215974
  Reported by:	mmel
  Inspired by:	ArchLinux, Gentoo, Debian
  Reviewed by:	tijl (implicit)

Comment 12 commit-hook freebsd_committer 2017-09-28 19:43:35 UTC
A commit references this bug:

Author: jbeich
Date: Thu Sep 28 19:43:06 UTC 2017
New revision: 450864
URL: https://svnweb.freebsd.org/changeset/ports/450864

  MFH: r450863

  audio/liba52: build PIC objects on all architectures

  PR:		215974
  Reported by:	mmel
  Inspired by:	ArchLinux, Gentoo, Debian
  Reviewed by:	tijl (implicit)
  Approved by:	ports-secteam blanket

_U  branches/2017Q3/