Skip to content

Commit

Permalink
[vm] Check for undefined symbols in assembly snapshots
Browse files Browse the repository at this point in the history
We don't check undefined symbols in our assembly snapshots. We
currently never emit undefined symbols, because Dart code only refers
to Dart code statically.

When adding static linking, we would like to have the option to have
PC relative calls to native libraries provided as relocatable files
(object files or static libraries).

Not checking would compile the symbols to dynamic linker, but we don't
support that `dart compile exe` at the moment. So we should add this
sanity check.

Also: Removes unused imports in relevant test.

Bug: #49418
Change-Id: I10701b82a1e8a06ce41271bd9183064addfb88f4
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251261
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
  • Loading branch information
dcharkes authored and Commit Bot committed Jul 15, 2022
1 parent da31d6f commit 0f456a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
10 changes: 7 additions & 3 deletions pkg/test_runner/lib/src/compiler_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,14 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
Command computeAssembleCommand(String tempDir, List arguments,
Map<String, String> environmentOverrides) {
late String cc;
String? shared, ldFlags;
String? shared;
var ldFlags = <String>[];
List<String>? target;
if (_isAndroid) {
cc = "$ndkPath/toolchains/$abiTriple-4.9/prebuilt/"
"$host-x86_64/bin/$abiTriple-gcc";
shared = '-shared';
ldFlags.add('-Wl,--no-undefined');
} else if (Platform.isLinux) {
if (_isSimArm || (_isArm && _configuration.useQemu)) {
cc = 'arm-linux-gnueabihf-gcc';
Expand All @@ -982,11 +984,13 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
cc = 'gcc';
}
shared = '-shared';
ldFlags.add('-Wl,--no-undefined');
} else if (Platform.isMacOS) {
cc = 'clang';
shared = '-dynamiclib';
ldFlags.add('-Wl,-undefined,error');
// Tell Mac linker to give up generating eh_frame from dwarf.
ldFlags = '-Wl,-no_compact_unwind';
ldFlags.add('-Wl,-no_compact_unwind');
if ({Architecture.arm64, Architecture.arm64c}
.contains(_configuration.architecture)) {
target = ['-arch', 'arm64'];
Expand Down Expand Up @@ -1022,7 +1026,7 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
var args = [
if (target != null) ...target,
if (ccFlags != null) ccFlags,
if (ldFlags != null) ldFlags,
...ldFlags,
shared,
'-o',
'$tempDir/out.aotsnapshot',
Expand Down
1 change: 0 additions & 1 deletion runtime/tests/vm/dart/run_appended_aot_snapshot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:dart2native/dart2native.dart';
import 'package:path/path.dart' as path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:dart2native/dart2native.dart';
import 'package:path/path.dart' as path;
Expand Down

0 comments on commit 0f456a8

Please sign in to comment.