Skip to content

Commit

Permalink
[vm] Fix some cross compilation issues from Linux to Windows
Browse files Browse the repository at this point in the history
Upstreamed changes from cl/579854752.

The cross-compiler checks some things that are check on Windows.
* Correct capitalization of filenames in includes.
* Field initialization order in constructors.

In the cross compilation process, some binaries are run on the host.
This unveiled missing `UnwindingRecords::GenerateRecordsInto`.

Finally, when emitting blob data with a symbol in assembly, the
`.type` directive is not supported but the format should still be
unix style assemble. So this CL introduces "win_gnu". This tool is
directly invoked from the build-rules in cl/579854752, and will not be
used until we address #28617.

TEST=windows bots

Change-Id: I94256589e8c231b45b8e14a63727c782416c2e98
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,pkg-win-release-try,pkg-win-release-arm64-try,vm-win-debug-arm64-try,vm-win-debug-x64c-try,vm-win-debug-x64-try,vm-msvc-windows-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335520
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
  • Loading branch information
dcharkes authored and Commit Queue committed Nov 13, 2023
1 parent 11ec96a commit 8440413
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
7 changes: 3 additions & 4 deletions runtime/bin/eventhandler_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ int OverlappedBuffer::GetRemainingLength() {
Handle::Handle(intptr_t handle)
: ReferenceCounted(),
DescriptorInfoBase(handle),
monitor_(),
handle_(reinterpret_cast<HANDLE>(handle)),
completion_port_(INVALID_HANDLE_VALUE),
event_handler_(nullptr),
data_ready_(),
pending_read_(nullptr),
pending_write_(nullptr),
last_error_(NOERROR),
flags_(0),
read_thread_id_(Thread::kInvalidThreadId),
read_thread_handle_(nullptr),
read_thread_starting_(false),
read_thread_finished_(false),
monitor_() {}
flags_(0) {}

Handle::~Handle() {
}
Expand Down Expand Up @@ -528,8 +528,7 @@ void ListenSocket::AcceptComplete(OverlappedBuffer* buffer,

// Insert the accepted socket into the list.
ClientSocket* client_socket = new ClientSocket(
buffer->client(),
std::move(std::unique_ptr<RawAddr>(raw_remote_addr)));
buffer->client(), std::unique_ptr<RawAddr>(raw_remote_addr));
client_socket->mark_connected();
client_socket->CreateCompletionPort(completion_port);
if (accepted_head_ == nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion runtime/bin/file_system_watcher_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "bin/file_system_watcher.h"

#include <WinIoCtl.h> // NOLINT
#include <winioctl.h> // NOLINT

#include "bin/builtin.h"
#include "bin/eventhandler.h"
Expand Down
6 changes: 3 additions & 3 deletions runtime/bin/file_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <string>

#include <Shlwapi.h> // NOLINT
#include <WinIoCtl.h> // NOLINT
#include <fcntl.h> // NOLINT
#include <io.h> // NOLINT
#include <winioctl.h> // NOLINT
#undef StrDup // defined in Shlwapi.h as StrDupW
#include <stdio.h> // NOLINT
#include <string.h> // NOLINT
Expand Down Expand Up @@ -328,8 +328,8 @@ class StringRAII {
s_ = origin.release();
}

explicit StringRAII(const char* s) : s_(s), own_(false) {}
explicit StringRAII(char* s) : s_(s), own_(true) {}
explicit StringRAII(const char* s) : own_(false), s_(s) {}
explicit StringRAII(char* s) : own_(true), s_(s) {}
~StringRAII() {
if (own_) {
free(const_cast<char*>(s_));
Expand Down
4 changes: 2 additions & 2 deletions runtime/platform/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
#define UNICODE
#endif

#include <Rpc.h>
#include <VersionHelpers.h>
#include <intrin.h>
#include <rpc.h>
#include <shellapi.h>
#include <versionhelpers.h>
#include <windows.h>
#include <winsock2.h>
#endif // defined(_WIN32)
Expand Down
11 changes: 10 additions & 1 deletion runtime/tools/bin_to_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ def Main():
output_file.write(".const\n")
output_file.write("public %s\n" % options.symbol_name)
output_file.write("%s label byte\n" % options.symbol_name)
elif options.target_os in ["win_gnu"]:
# Cross compilation from Linux to Windows.
if options.executable:
output_file.write(".text\n")
else:
output_file.write(".section .rodata\n")
output_file.write(".global %s\n" % options.symbol_name)
output_file.write(".balign 32\n")
output_file.write("%s:\n" % options.symbol_name)
else:
if options.executable:
output_file.write(".text\n")
Expand Down Expand Up @@ -97,7 +106,7 @@ def Main():
if incbin:
output_file.write(".incbin \"%s\"\n" % options.input)

if options.target_os not in ["mac", "ios", "win"]:
if options.target_os not in ["mac", "ios", "win", "win_gnu"]:
output_file.write(".size {0}, .-{0}\n".format(options.symbol_name))

if options.size_symbol_name:
Expand Down
4 changes: 4 additions & 0 deletions runtime/vm/unwinding_records.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

namespace dart {

const void* UnwindingRecords::GenerateRecordsInto(intptr_t offset,
uint8_t* target_buffer) {
return nullptr;
}
void UnwindingRecords::RegisterExecutablePage(Page* page) {}
void UnwindingRecords::UnregisterExecutablePage(Page* page) {}

Expand Down

0 comments on commit 8440413

Please sign in to comment.