Building with -fPIC
x265 failed to build on Debian's arm64 and armhf auto builders with
/usr/bin/c++ -fPIC -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic,-znoexecstack -Wl,-z,relro -Wl,--as-needed -shared -Wl,-soname,libx265.so.35 -o libx265.so.35 encoder/CMakeFiles/encoder.dir/analysis.cpp.o encoder/CMakeFiles/encoder.dir/search.cpp.o encoder/CMakeFiles/encoder.dir/bitcost.cpp.o encoder/CMakeFiles/encoder.dir/motion.cpp.o encoder/CMakeFiles/encoder.dir/slicetype.cpp.o encoder/CMakeFiles/encoder.dir/frameencoder.cpp.o encoder/CMakeFiles/encoder.dir/framefilter.cpp.o encoder/CMakeFiles/encoder.dir/level.cpp.o encoder/CMakeFiles/encoder.dir/nal.cpp.o encoder/CMakeFiles/encoder.dir/sei.cpp.o encoder/CMakeFiles/encoder.dir/sao.cpp.o encoder/CMakeFiles/encoder.dir/entropy.cpp.o encoder/CMakeFiles/encoder.dir/dpb.cpp.o encoder/CMakeFiles/encoder.dir/ratecontrol.cpp.o encoder/CMakeFiles/encoder.dir/reference.cpp.o encoder/CMakeFiles/encoder.dir/encoder.cpp.o encoder/CMakeFiles/encoder.dir/api.cpp.o encoder/CMakeFiles/encoder.dir/weightPrediction.cpp.o common/CMakeFiles/common.dir/vec/vec-primitives.cpp.o common/CMakeFiles/common.dir/primitives.cpp.o common/CMakeFiles/common.dir/pixel.cpp.o common/CMakeFiles/common.dir/dct.cpp.o common/CMakeFiles/common.dir/ipfilter.cpp.o common/CMakeFiles/common.dir/intrapred.cpp.o common/CMakeFiles/common.dir/loopfilter.cpp.o common/CMakeFiles/common.dir/constants.cpp.o common/CMakeFiles/common.dir/cpu.cpp.o common/CMakeFiles/common.dir/version.cpp.o common/CMakeFiles/common.dir/threading.cpp.o common/CMakeFiles/common.dir/threadpool.cpp.o common/CMakeFiles/common.dir/wavefront.cpp.o common/CMakeFiles/common.dir/md5.cpp.o common/CMakeFiles/common.dir/bitstream.cpp.o common/CMakeFiles/common.dir/yuv.cpp.o common/CMakeFiles/common.dir/shortyuv.cpp.o common/CMakeFiles/common.dir/picyuv.cpp.o common/CMakeFiles/common.dir/common.cpp.o common/CMakeFiles/common.dir/param.cpp.o common/CMakeFiles/common.dir/frame.cpp.o common/CMakeFiles/common.dir/framedata.cpp.o common/CMakeFiles/common.dir/cudata.cpp.o common/CMakeFiles/common.dir/slice.cpp.o common/CMakeFiles/common.dir/lowres.cpp.o common/CMakeFiles/common.dir/piclist.cpp.o common/CMakeFiles/common.dir/predict.cpp.o common/CMakeFiles/common.dir/scalinglist.cpp.o common/CMakeFiles/common.dir/quant.cpp.o common/CMakeFiles/common.dir/deblock.cpp.o -lpthread -lrt
/usr/bin/ld: encoder/CMakeFiles/encoder.dir/analysis.cpp.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
encoder/CMakeFiles/encoder.dir/analysis.cpp.o: error adding symbols: Bad value
Building with -fPIC fixes this. Could you please build with -fPIC by default or add a option to the build system so that we can specify that we want builds with -fPIC?
Related to that: we see lintian erros on x86-32 if the assembler code is enabled: https://lintian.debian.org/maintainer/pkg-multimedia-maintainers@lists.alioth.debian.org.html#x265. It'd be nice if PIC was not undefined in the assembler code if we explicitely want PIC builds.
See https://buildd.debian.org/status/fetch.php?pkg=x265&arch=arm64&ver=1.4-1&stamp=1417364453 and https://buildd.debian.org/status/fetch.php?pkg=x265&arch=armhf&ver=1.4-1&stamp=1417365661 if you are interested in the build logs.
Comments (10)
-
reporter -
@ Sebastian Ramacher: might be a little OT, but could you add a high_bit_depth build of x265 to the Debian release too? I'm always doing this for my Ubuntu PPA builds.
-
related to
#88 -
How much does this patch help? http://pastie.org/9759482
This makes -fPIC a cmake option that can be forced on for the original build case, and can be forced off for the issue in
#88 -
reporter Shouldn't that be more like that?
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -122,8 +122,13 @@ add_definitions(-Wall -Wextra -Wshadow) add_definitions(-D__STDC_LIMIT_MACROS=1) if(X64 AND NOT WIN32) + option(ENABLE_PIC "Enable Position Independent Code" ON) + else() + option(ENABLE_PIC "Enable Position Independent Code" OFF) + endif(X64 AND NOT WIN32) + if (ENABLE_PIC) add_definitions(-fPIC) - endif(X64 AND NOT WIN32) + endif() if(X86 AND NOT X64) add_definitions(-march=i686) endif() diff --git a/source/cmake/CMakeASM_YASMInformation.cmake b/source/cmake/CMakeASM_YASMInformation.cmake --- a/source/cmake/CMakeASM_YASMInformation.cmake +++ b/source/cmake/CMakeASM_YASMInformation.cmake @@ -2,7 +2,10 @@ set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) if(X64) - list(APPEND ASM_FLAGS -DARCH_X86_64=1 -DPIC) + list(APPEND ASM_FLAGS -DARCH_X86_64=1) + if (ENABLE_PIC) + list(APPEND ASM_FLAGS -DPIC) + endif() if(APPLE) set(ARGS -f macho64 -m amd64 -DPREFIX) elseif(UNIX AND NOT CYGWIN)
Otherwise running
cmake -DENABLE_PIC=ON
will never have an effect on any non x86-64 system, e.g. Debian's arm64 and armhf architectures. -
reporter On 2014-12-04 02:07:23, Steve Borho wrote:
Thank you. I'll look at the patch today and report back later.
Cheers
-
reporter On 2014-12-03 18:35:39, djcj wrote:
Once I've got x265 building on all architectures I can look at that. Where is your PPA?
Cheers
-
@ Sebastian Ramacher: https://launchpad.net/~djcj/+archive/ubuntu/hybrid
-
uhm yeah, my patch was a bit of a turd. I'll go ahead and push a fixed version
-
- changed status to resolved
cmake: allow position independent code to be generally configurable (fixes
#91)Allow the builder to over-ride the default
→ <<cset afdcb68dace4>>
- Log in to comment
Regarding undefining PIC on x86-32: I'm not sure if that actually solves it. It would be nice to find a solution for that though.