-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Hi, I’m trying to build the latest version of MuJS on Ubuntu 20.04, but I’m encountering issues with generating Position-Independent Code using the -fPIC flag. Despite adding the -fPIC flag, using CFLAGS or by modifying the Makefile to include -fPIC, the resulting build is not generating Position-Independent Code.
Even after using the -fPIC flag, the resulting build still fails to generate PIC, causing this error when trying to link MuJS into MPV:
/usr/bin/ld: /mnt/Windows/Desktop/Movies/mpv/mujs/build/release/libmujs.a(libmujs.o): relocation R_X86_64_PC32 against symbol` stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
I tried many versions of mujs but the problem persist. In older versions of mpv where mujs doesn't require to be Position Independent Code i have no issues, however mpv 0.40 requires it and i cannot build it.
Steps to Reproduce:
Download and extract the latest MuJS source.
Run the command: make CFLAGS="-fPIC" prefix=/mnt/custom/path install
or Modify the Makefile to include -fPIC in the CFLAGS (as follows):
CFLAGS := -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter -fPIC
Extract the .a archive with ar:
ar x libmujs.a
Run the following command to check for relocations:
readelf --relocs *.o | grep R_X86_64_PC32
You will see R_X86_64_PC32 in the output, indicating that the code is not position-independent.