mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 20:29:39 +00:00
Revert "[build, vm] Access TLS with less code."
This reverts commit aa79cf2708
.
Reason for revert: -fPIC is needed in more places than the CL adds it to, see CI builds at https://ci.chromium.org/ui/p/dart-internal/builders/ci/dart-sdk-linux-riscv64-dev/405/overview
Original change's description:
> [build, vm] Access TLS with less code.
>
> - Avoid TLS initialization checks by using inline initialization.
> - Avoid global offset table indirection by reducing -fPIC to -fPIE.
>
> out/ReleaseXARM64/exe.stripped/dart_precompiled_runtime
> 11137992 -> 11274776 (-1.21%)
>
> We still need -fPIC in some places because we build a few shared libraries for FFI, so copy some of Fuchsia's GN setup to use -fPIE or -fPIC as appropriate.
>
> TEST=ci
> Change-Id: I6402fce3366a9c4b2741ffb4811562292b8ecb71
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285704
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
Change-Id: Idacb7869e9fa9ad0f7ed7b0caa2bae19deece7d0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286144
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: William Hesse <whesse@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
08b57e0457
commit
ec53fdd0bf
|
@ -18,17 +18,3 @@ config("product") {
|
|||
"PRODUCT",
|
||||
]
|
||||
}
|
||||
|
||||
config("shared_library_config") {
|
||||
if (current_os == "android" || current_os == "fuchsia" ||
|
||||
current_os == "linux" || current_os == "mac") {
|
||||
cflags = [ "-fPIC" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("executable_config") {
|
||||
if (current_os == "android" || current_os == "fuchsia" ||
|
||||
current_os == "linux" || current_os == "mac") {
|
||||
cflags = [ "-fPIE" ]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,8 +313,7 @@ if (is_win) {
|
|||
}
|
||||
|
||||
# Executable defaults.
|
||||
_executable_configs =
|
||||
_native_compiler_configs + [ "//build/config:executable_config" ]
|
||||
_executable_configs = _native_compiler_configs
|
||||
if (is_win) {
|
||||
_executable_configs += _windows_linker_configs
|
||||
} else if (is_mac) {
|
||||
|
@ -343,8 +342,7 @@ set_defaults("static_library") {
|
|||
}
|
||||
|
||||
# Shared library defaults (also for components in component mode).
|
||||
_shared_library_configs =
|
||||
_native_compiler_configs + [ "//build/config:shared_library_config" ]
|
||||
_shared_library_configs = _native_compiler_configs
|
||||
if (is_win) {
|
||||
_shared_library_configs += _windows_linker_configs
|
||||
} else if (is_mac) {
|
||||
|
|
|
@ -249,6 +249,17 @@ config("compiler") {
|
|||
]
|
||||
}
|
||||
|
||||
# We need -fPIC:
|
||||
# 1. On ARM for tcmalloc.
|
||||
# 2. On Android.
|
||||
# 3. When using the sanitizers.
|
||||
# Otherwise there is a performance hit, in particular on ia32.
|
||||
if (is_android || is_asan || is_lsan || is_msan || is_tsan || is_ubsan ||
|
||||
(is_linux && current_cpu != "x86") || is_fuchsia) {
|
||||
cflags += [ "-fPIC" ]
|
||||
ldflags += [ "-fPIC" ]
|
||||
}
|
||||
|
||||
# Linux-specific compiler flags setup.
|
||||
# ------------------------------------
|
||||
if (is_linux) {
|
||||
|
|
|
@ -1036,6 +1036,9 @@ shared_library("entrypoints_verification_test") {
|
|||
# The only effect of DART_SHARED_LIB is to export the Dart API.
|
||||
"DART_SHARED_LIB",
|
||||
]
|
||||
if (is_linux || is_android) {
|
||||
cflags = [ "-fPIC" ]
|
||||
}
|
||||
if (is_win) {
|
||||
# TODO(dartbug.com/40579): This wrongly links in dart.exe on precompiled.
|
||||
libs = [ "dart.lib" ]
|
||||
|
@ -1052,6 +1055,9 @@ shared_library("ffi_test_dynamic_library") {
|
|||
# The only effect of DART_SHARED_LIB is to export the Dart API.
|
||||
"DART_SHARED_LIB",
|
||||
]
|
||||
if (is_linux || is_android) {
|
||||
cflags = [ "-fPIC" ]
|
||||
}
|
||||
if (is_win) {
|
||||
# TODO(dartbug.com/40579): This wrongly links in dart.exe on precompiled.
|
||||
libs = [ "dart.lib" ]
|
||||
|
@ -1085,6 +1091,9 @@ shared_library("ffi_test_functions") {
|
|||
# The only effect of DART_SHARED_LIB is to export the Dart API.
|
||||
"DART_SHARED_LIB",
|
||||
]
|
||||
if (is_linux || is_android) {
|
||||
cflags = [ "-fPIC" ]
|
||||
}
|
||||
if (is_win) {
|
||||
# TODO(dartbug.com/40579): This wrongly links in dart.exe on precompiled.
|
||||
libs = [ "dart.lib" ]
|
||||
|
|
|
@ -20,6 +20,11 @@ OSThread* OSThread::thread_list_head_ = NULL;
|
|||
Mutex* OSThread::thread_list_lock_ = NULL;
|
||||
bool OSThread::creation_enabled_ = false;
|
||||
|
||||
thread_local ThreadState* OSThread::current_vm_thread_ = NULL;
|
||||
#if defined(DEBUG)
|
||||
thread_local bool ThreadInterruptScope::in_thread_interrupt_scope_ = false;
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_TIMELINE)
|
||||
inline void UpdateTimelineTrackMetadata(const OSThread& thread) {
|
||||
RecorderSynchronizationLockScope ls;
|
||||
|
|
|
@ -306,9 +306,7 @@ class OSThread : public BaseThread {
|
|||
static OSThread* thread_list_head_;
|
||||
static bool creation_enabled_;
|
||||
|
||||
// Inline initialization is important for avoiding unnecessary TLS
|
||||
// initialization checks at each use.
|
||||
static inline thread_local ThreadState* current_vm_thread_ = nullptr;
|
||||
static thread_local ThreadState* current_vm_thread_;
|
||||
|
||||
friend class IsolateGroup; // to access set_thread(Thread*).
|
||||
friend class OSThreadIterator;
|
||||
|
@ -414,7 +412,7 @@ class ThreadInterruptScope : public ValueObject {
|
|||
|
||||
private:
|
||||
ThreadState* saved_current_vm_thread_;
|
||||
static inline thread_local bool in_thread_interrupt_scope_ = false;
|
||||
static thread_local bool in_thread_interrupt_scope_;
|
||||
#endif // DEBUG
|
||||
};
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "dart:io";
|
||||
|
||||
// Mmmm... pie!
|
||||
main() {
|
||||
if (!Platform.isLinux) return; // readelf is a Linux tool.
|
||||
// Modern Mac and Android binaries are always PIE.
|
||||
// Fuchsia binaries are always PIE.
|
||||
|
||||
var result = Process.runSync("readelf", ["-h", Platform.resolvedExecutable]);
|
||||
print("stdout:");
|
||||
print(result.stdout);
|
||||
print("stderr:");
|
||||
print(result.stderr);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
throw "readelf failed";
|
||||
}
|
||||
|
||||
// A position-dependent executable outputs "EXEC (Executable file)".
|
||||
if (!result.stdout.contains("DYN (Position-Independent Executable file)") &&
|
||||
!result.stdout.contains("DYN (Shared object file)")) {
|
||||
throw "Standalone VM should be a position-independent executable";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue