Commit 628a8496 by Ivan Krasin

Fix SwiftShader's libEGL build under ThinLTO.

Linking libEGL.so of the SwiftShader's flavor requires the linker to be too smart (there's a heavy reliance on garbage collecting unused symbols, for which there is no guarantees in the general case). In ThinLTO case, garbage collection is still not as sofisticated, as in other cases, so it fails to link the target complaining about undefined symbols. The workaround is to prevent Clang from splitting the bitcode files in the question into two, and making the GC problem a bit easier. Eventually, ThinLTO might get a better GC, but it might be a good idea to not rely on this feature in the source code. At least, no other targets in Chromium do. BUG=chromium:686980 Change-Id: Ib44f65c4825cc3f6cd24695738a71ca4661f0bfb Reviewed-on: https://swiftshader-review.googlesource.com/9308Tested-by: 's avatarIvan Krasin <krasin@chromium.org> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 30385f0f
......@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/toolchain/toolchain.gni")
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_libEGL_private_config") {
defines = [ "EGL_EGLEXT_PROTOTYPES" ]
......@@ -82,6 +84,13 @@ shared_library("swiftshader_libEGL") {
[ "-Wl,--version-script=" + rebase_path("exports.map", root_build_dir) ]
}
if (use_thin_lto) {
# https://crbug.com/686980
# This target relies on the linker to be smart and garbage collect unused symbols.
# It is not the case for LLD + ThinLTO, so we have to use this ugly workaround.
cflags = ["-Xclang", "-fno-lto-unit"]
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment