[vm] Fix some cross compilation issues from Linux to Windows

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 https://github.com/dart-lang/sdk/issues/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>
This commit is contained in:
Daco Harkes 2023-11-13 14:25:28 +00:00 committed by Commit Queue
parent 11ec96ab8a
commit 84404136e9
6 changed files with 23 additions and 11 deletions

View file

@ -116,6 +116,7 @@ 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),
@ -123,12 +124,11 @@ Handle::Handle(intptr_t handle)
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() {
}
@ -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) {

View file

@ -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"

View file

@ -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
@ -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_));

View file

@ -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)

View file

@ -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")
@ -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:

View file

@ -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) {}