[x265] [PATCH] Fix Clang build error when linking incompatible ABI (stack unwinding schemes).

den c dncodr at gmail.com
Thu May 29 23:08:09 CEST 2014


Hi. Recently I faced with trouble when compiling x265 with Clang.

CMakeFiles/cli.dir/input/input.cpp.obj:(.text+0x119): undefined
reference to `_Unwind_Resume'
CMakeFiles/cli.dir/input/input.cpp.obj:(.eh_frame+0x13): undefined
reference to `__gxx_personality_v0'
/bin/ld.exe: CMakeFiles/cli.dir/input/input.cpp.obj: bad reloc address
0x13 in section `.eh_frame'
collect2.exe: error: ld returned 1 exit status
clang++.exe: error: linker (via gcc) command failed with exit code 1
(use -v to see invocation)
make[2]: *** [x265.exe] Error 1

After some digging it turned out that clang has limited support for
windows exception handling. As you dont throw it anyway, this simple
patch fixes that just turning off without any hurt. As side effect
executable size little smaller.
OTOH i cant precisely say how will behave std:: functions which throw
exceptions, i you use any of that, so i didnt include  -fno-exceptions
in gcc branch.

# HG changeset patch
# User Den Scherbin <dncodr at gmail.com>
# Date 1401396136 -10800
#      Thu May 29 23:42:16 2014 +0300
# Node ID c579324661faf76e8f3b78dc10ff7b7e33750c9f
# Parent  91330e7dddd7ba02028cad7a8d458b79d38362f6
Disable exceptions. Fixes Clang linker errors.

diff -r 91330e7dddd7 -r c579324661fa source/CMakeLists.txt
--- a/source/CMakeLists.txt	Sat May 24 00:07:16 2014 +0900
+++ b/source/CMakeLists.txt	Thu May 29 23:42:16 2014 +0300
@@ -115,7 +115,7 @@
 elseif(CLANG)
     # treat clang roughly like gcc
     set(GCC 1)
-    add_definitions(-Wall -Wextra -Wshadow -ffast-math)
+    add_definitions(-Wall -Wextra -Wshadow -ffast-math -fno-exceptions)
 elseif(CMAKE_COMPILER_IS_GNUCXX)
     add_definitions(-Wall -Wextra -Wshadow -ffast-math)
     check_cxx_compiler_flag(-Wno-narrowing GCC_HAS_NO_NARROWING)


More information about the x265-devel mailing list