Skip to content

Commit

Permalink
gn bootstrap: Explicitly pass -lpthread when linking with --use-custo…
Browse files Browse the repository at this point in the history
…m-libcxx

https://chromium-review.googlesource.com/c/1460187 ("Fix gn build on 'Build
From Tarball' bot") together with
https://gn-review.googlesource.com/c/gn/+/4000 ("Pass -lpthread when linking
instead of -pthread") have caused the GN bootstrap process to fail when
--use-custom-libcxx is not used.

The reason is that -nodefaultlibs (passed to the compiler when linking with
--use-custom-libcxx) causes -pthread to be ignored. To work around that,
that GN CL started passing -lpthread so that it was added back to the
command-line. However, if we are _not_ using --use-custom-libcxx, the whole
process fails because -lpthread is specified at the wrong position in the
command-line and the symbols are not resolved correctly.

In this CL, make the --use-custom-libcxx build explicitly pass -lpthread to
the linker so that we can later go back to passing -pthread in the GN build,
as the compiler then knows where to put the right flags in the command line.

Bug: 934793
Change-Id: Id8bf242bf461fb5146e1ac28d187082c43fdafbb
Reviewed-on: https://chromium-review.googlesource.com/c/1482959
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634657}
  • Loading branch information
Raphael Kubo da Costa authored and Commit Bot committed Feb 22, 2019
1 parent 39ced93 commit 1ee5a08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/gn/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def append_to_env(var, vals):
os.putenv(var, os.environ.get(var, '') + ' ' + ' '.join(vals))

append_to_env('LDFLAGS', [
'-nodefaultlibs', 'libc++.gn.so', '-lc', '-lm',
'-nodefaultlibs', 'libc++.gn.so',
'-lpthread', '-lc', '-lm',
'-Wl,-rpath="\$$ORIGIN/."', '-Wl,-rpath-link=.'
])
append_to_env('CXXFLAGS', [
Expand Down

0 comments on commit 1ee5a08

Please sign in to comment.