Skip to content

Fails to build on x86 and armhf due to undefined reference to __va_copy #77

Closed

Description

@jirutka
make -j1 -C src pactester pymod
...
cd js/src
find . -name "libjs.a" -exec cp -f {} .. \;
make[1]: Leaving directory '/home/buildozer/aports/testing/pacparser/src/pacparser-1.3.6/src/spidermonkey'
gcc -shared -g -DXP_UNIX -Wall -DVERSION=v3.4.0-247-g939ac0d -Ispidermonkey/js/src -Wl,--as-needed -Wl,-soname=libpacparser.so.1 -Wl,-exclude-libs=libjs.a -o libpacparser.so.1 pacparser.o libjs.a -lm
ln -sf libpacparser.so.1 libpacparser.so
gcc -g -DXP_UNIX -Wall -DVERSION=v3.4.0-247-g939ac0d -Ispidermonkey/js/src -Wl,--as-needed pactester.c -o pactester -lpacparser -L. -I.
./libpacparser.so: undefined reference to `__va_copy'
collect2: error: ld returned 1 exit status
make: *** [Makefile:99: pactester] Error 1
make: Leaving directory '/home/buildozer/aports/testing/pacparser/src/pacparser-1.3.6/src'

It builds fine only on x86_64.

Activity

  1. added a commit that references this issue on Jun 11, 2016
  2. manugarg commented on Sep 26, 2016

    @manugarg
    Owner

    Digging this a bit further, I changed Makefile to set HAVE_VA_COPY in Sep 2010, by this change:
    53ebc46#diff-f57f2991a6aa25fe45d8036c51bf8b4d

    Not sure why it wasn't reported until now. Also, debian is able to build it just fine:
    https://packages.debian.org/unstable/libpacparser1

  3. manugarg commented on Sep 26, 2016

    @manugarg
    Owner

    On further investigation, it seems that GCC defines MACRO __va_copy to be a builtin:
    https://github.com/gcc-mirror/gcc/blob/master/gcc/ginclude/stdarg.h#L54

    I wonder why are you getting this error. I'll try to build it myself to see if I can reproduce it.

  4. guangzhi-ran-hpeprod commented on Mar 9, 2020

    @guangzhi-ran-hpeprod

    See this issue on apline. Works by replacing __va_copy with va_copy.

  5. manugarg commented on Apr 4, 2022

    @manugarg
    Owner

    This issue is super old now. Please re-open if it's still an issue.

  6. ptrcnull commented on Dec 20, 2022

    @ptrcnull

    it is still an issue: https://gitlab.alpinelinux.org/ptrcnull/aports/-/jobs/931243

    gcc -g -DXP_UNIX -Wall -DVERSION= -Ispidermonkey/js/src -Wl,--as-needed,-O1,--sort-common pactester.c pacparser.o spidermonkey/libjs.a -o pactester -lm -L. -I.
    /usr/lib/gcc/i586-alpine-linux-musl/12.2.1/../../../../i586-alpine-linux-musl/bin/ld: spidermonkey/libjs.a(jsprf.o): in function `BuildArgArray':
    /builds/ptrcnull/aports/testing/pacparser/src/pacparser-1.4.0/src/spidermonkey/js/src/jsprf.c:644: undefined reference to `__va_copy'
    

    please reopen the issue

  7. ptrcnull commented on Dec 20, 2022

    @ptrcnull

    why is __va_copy even used instead of just va_copy (which is standardized and widely used)?

    it looks like 53ebc46 was some weird debian ppc workaround, is there any issue / bug report related to that?

  8. nekopsykose commented on Dec 20, 2022

    @nekopsykose

    why is __va_copy even used instead of just va_copy (which is standardized and widely used)?

    because this code is much older than you think, and the 'standardised' va_copy wasn't really standardised prior to 2011/10. i forget which standard.

    so, at the time, on powerpc32 (yes, that old), va_copy most likely didn't exist, but the libc provided __va_copy to not clash with a potential future implementation. you'll have to do some archaelogical digging to find it for sure.

    these days though, sure, as long as you target the new standards you can use va_copy instead.

  9. ptrcnull commented on Dec 20, 2022

    @ptrcnull

    the 'standardised' va_copy wasn't really standardised prior to 2011/10

    from what i've been able to find (it's a bit unclear though, as the standard costs 60 dollars to download (😠)), va_copy was supposed to be guaranteed to exist since at least C99

  10. moszajca commented on Jan 12, 2024

    @moszajca

    Still an issue on Alpine:

    6.215 python ../tests/runtests.py
    6.229 Build dir: %s /app/pacparser-1.4.2/src/../tests/../src/pymod/build
    6.229 ['lib.linux-aarch64-cpython-311', 'temp.linux-aarch64-cpython-311']
    6.229 Traceback (most recent call last):
    6.229   File "/app/pacparser-1.4.2/src/../tests/runtests.py", line 47, in runtests
    6.229     import pacparser
    6.229   File "/app/pacparser-1.4.2/src/../tests/../src/pymod/build/lib.linux-aarch64-cpython-311/pacparser/__init__.py", line 31, in <module>
    6.230     from pacparser import _pacparser
    6.230 ImportError: Error relocating /app/pacparser-1.4.2/src/../tests/../src/pymod/build/lib.linux-aarch64-cpython-311/pacparser/_pacparser.cpython-311-aarch64-linux-musl.so: __va_copy: symbol not found
    

    Using va_copy fixes it

  11. self-assigned this
    on Jan 12, 2024
  12. manugarg commented on Jan 12, 2024

    @manugarg
    Owner

    I think I understand this issue better now. Alpine uses musl for C library and musl doesn't define __va_copy. I'll submit a fix soon.

  13. added a commit that references this issue on Jan 12, 2024
  14. manugarg commented on Jan 13, 2024

    @manugarg
    Owner

    It guess it's more than just alpine being an issue. It's the combination of alpine and some platforms. In any case, it seems better choice is to use va_copy everywhere now. I've done that.

  15. moszajca commented on Jan 15, 2024

    @moszajca

    @manugarg thanks for the update. Do you plan to release it soon?

  16. manugarg commented on Jan 15, 2024

    @manugarg
    Owner

    Yeah, I plan to cut a release in a couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions