Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ ACCEPTABLE_ARGUMENTS = set([
'pnacl_newlib_dir',
# Allows override of the pnacl newlib toolchain directory.
'saigo_newlib_dir',
# MinGW install directory, for Windows builds. Required.
'mingw_dir',
# Allows overriding the version number in the toolchain's
# FEATURE_VERSION file. This is used for PNaCl ABI compatibility
# testing.
Expand Down Expand Up @@ -2335,8 +2337,10 @@ def MakeWindowsEnv(platform=None):
LIBS = ['ws2_32', 'advapi32'],
# TODO(bsy) remove 4355 once cross-repo
# NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in.
CCFLAGS = ['/EHsc', '/WX', '/wd4355', '/wd4800']
CCFLAGS = ['/EHsc', '/wd4355', '/wd4800']
)
if windows_env.Bit('werror'):
windows_env.Append(CCFLAGS = '/WX')

# This linker option allows us to ensure our builds are compatible with
# Chromium, which uses it.
Expand All @@ -2346,16 +2350,10 @@ def MakeWindowsEnv(platform=None):
# We use the GNU assembler (gas) on Windows so that we can use the
# same .S assembly files on all platforms. Microsoft's assembler uses
# a completely different syntax for x86 code.
if windows_env.Bit('build_x86_64'):
# This assembler only works for x86-64 code.
windows_env['WINASM'] = \
windows_env.File('$SOURCE_ROOT/third_party/mingw-w64/mingw/bin/'
'x86_64-w64-mingw32-as.exe').abspath
else:
# This assembler only works for x86-32 code.
windows_env['WINASM'] = \
windows_env.File('$SOURCE_ROOT/third_party/gnu_binutils/files/'
'as').abspath
mingw_dir = os.path.abspath(ARGUMENTS['mingw_dir'])
windows_env['MINGW_BIN'] = os.path.join(mingw_dir, 'bin')
windows_env['WINASM'] = os.path.join(windows_env['MINGW_BIN'], 'as.exe')

return windows_env

(windows_debug_env,
Expand Down
2 changes: 2 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ def FindReadElf():
candidates.append(os.path.join(path, 'readelf'))

for readelf in candidates:
if pynacl.platform.IsWindows():
readelf += '.exe'
if os.path.exists(readelf):
return readelf

Expand Down
28 changes: 0 additions & 28 deletions scons.bat

This file was deleted.

2 changes: 1 addition & 1 deletion site_scons/site_tools/naclsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def __call__(self, target, source, env, for_signature):
# Default to the .lnk suffix for the benefit of the Phar Lap
# linkloc linker, which likes to append an .lnk suffix if
# none is given.
if env.has_key('TEMPFILESUFFIX'):
if 'TEMPFILESUFFIX' in env:
suffix = env.subst('$TEMPFILESUFFIX')
else:
suffix = '.lnk'
Expand Down
46 changes: 0 additions & 46 deletions site_scons/site_tools/target_platform_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from __future__ import print_function

import json
import os
import time
import SCons.Script
Expand Down Expand Up @@ -235,22 +234,6 @@ def _CoverageInstall(dest, source, env):
else:
env['PRECOVERAGE_INSTALL'](dest, source, env)

def _FindDepotTools():
paths = os.environ['PATH'].split(os.pathsep)
for path in paths:
if os.path.split(path)[-1] == 'depot_tools':
return path
raise Exception('Cannot find depot_tools in PATH!')


def _FindVSFilesPath():
vs = os.path.join(_FindDepotTools(), 'win_toolchain', 'vs_files')
for version in os.listdir(vs):
path = os.path.join(vs, version)
if os.path.exists(os.path.join(path, 'Windows Kits')):
return path
raise Exception('Cannot find MSVC in depot_tools!')


def generate(env):
# NOTE: SCons requires the use of this name, which fails gpylint.
Expand Down Expand Up @@ -278,35 +261,6 @@ def generate(env):

# Load various Visual Studio related tools.
if use_msvc_tools:
# Our bots have a file that encodes necessary environment vars in a .json
# file. Find it, read it, and set ENVs accordingly.
vs_files_path = _FindVSFilesPath()
env_json_file = os.path.join(vs_files_path, 'Windows Kits',
'10', 'bin', 'SetEnv.x64.json')
if not os.path.exists(env_json_file):
raise Exception('Could not find environment file for MSVC!')

with open(env_json_file) as f:
parsed_json_env = json.load(f)['env']

# Example keys: INCLUDE, LIB, PATH, LIBPATH
for key, paths in parsed_json_env.items():
for path in paths:
final_path = os.path.join(vs_files_path, *path)
env.AppendENVPath(key, final_path)

# VS autodetection relies on vswhere.exe, which our bots don't have.
# Disable VS autodetection by setting MSVC_USE_SCRIPT to False, and set
# location and version directly.
env['MSVC_USE_SCRIPT'] = False
env['MSSDK_DIR'] = vs_files_path
# If this gets updated, we may also need to update scons, as this is the
# newest version that our scons knows about.
# VS_VERSION 2022 will be MSVC_VERSION 14.3
with open(os.path.join(vs_files_path, 'VS_VERSION')) as f:
assert f.read().strip() == '2019'
env['MSVC_VERSION'] = '14.2'

env.Tool('as')
env.Tool('msvs')
env.Tool('windows_hard_link')
Expand Down
6 changes: 4 additions & 2 deletions src/shared/platform/build.scons
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import os
import platform

Import('env')
env.Append(CCFLAGS=['-Wno-cast-function-type-mismatch',
'-Wno-unknown-warning-option'])

if not env.Bit('windows'): # FIXME: better MSVC test
env.Append(CCFLAGS=['-Wno-cast-function-type-mismatch',
'-Wno-unknown-warning-option'])

platform_inputs = []

Expand Down
3 changes: 2 additions & 1 deletion src/trusted/nacl_base/build.scons
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ if env.Bit('built_elsewhere'):

# Modern compilers detect that the NACL_ASSERT_IS_POINTER(x) macro does not
# actually use x, which can trigger false warnings.
env.Append(CCFLAGS='-Wno-unused-but-set-variable')
if not env.Bit('windows'): # FIXME: better MSVC test
env.Append(CCFLAGS='-Wno-unused-but-set-variable')

nacl_base_lib_inputs = [
'nacl_refcount.c',
Expand Down
30 changes: 22 additions & 8 deletions src/trusted/platform_qualify/win/nacl_dep_qualify.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,35 @@

#include "native_client/src/include/portability.h"

#include <setjmp.h>
#include <stdlib.h>
#include <stdio.h>

#include "native_client/src/trusted/platform_qualify/nacl_dep_qualify.h"


int NaClAttemptToExecuteDataAtAddr(uint8_t *thunk_buffer, size_t size) {
/*
* All supported versions of Windows have DEP. No need to test this.
*/
return 1;
int got_fault = 0;
nacl_void_thunk thunk = NaClGenerateThunk(thunk_buffer, size);
__try {
thunk();
} __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION
? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
got_fault = 1;
}
return got_fault;
}

/*
* Returns 1 if Data Execution Prevention is present and working.
*/
int NaClAttemptToExecuteData(void) {
/*
* All supported versions of Windows have DEP. No need to test this.
*/
return 1;
int result;
uint8_t *thunk_buffer = malloc(64);
if (NULL == thunk_buffer) {
return 0;
}
result = NaClAttemptToExecuteDataAtAddr(thunk_buffer, 64);
free(thunk_buffer);
return result;
}
2 changes: 1 addition & 1 deletion tests/gdb/gdb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


if sys.platform == 'win32':
RETURNCODE_KILL = -9
RETURNCODE_KILL = -9 & 0xffffffff
else:
RETURNCODE_KILL = -9 & 0xff

Expand Down
2 changes: 2 additions & 0 deletions tests/redir/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
redir_test.stderr eol=lf
redir_test.stdout eol=lf
5 changes: 5 additions & 0 deletions tests/run_py/nacl.scons
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ elif env.Bit('nacl_glibc'):
# With the new glibc port, it won't work at all.
Return()

if env['TRUSTED_ENV'].Bit('windows'):
# To find readelf. Saigo also has a readelf but it's named x86_64-nacl-readelf (etc.)
env = env.Clone()
env.PrependENVPath('PATH', env['TRUSTED_ENV']['MINGW_BIN'])

sel_ldr = env.GetSelLdr()
if sel_ldr is None:
print('WARNING: no sel_ldr found. Skipping test %s' % name)
Expand Down
4 changes: 2 additions & 2 deletions tests/toolchain/nacl.scons
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ if env.Bit('bitcode') or env.Bit('nacl_clang'):
EXTRA_CCFLAGS='-DSHOULD_INLINE=' + str(should_inline),
# inline case is currently broken:
# https://code.google.com/p/nativeclient/issues/detail?id=4170
is_broken=should_inline)
is_broken=should_inline and not env.Bit('saigo'))
AddIntrinsicTest(env, 'llvm_math_intrinsics.cc', '0',
golden_file=env.File('llvm_math_intrinsics.stdout'))
# Also test the math functions with -ffast-math, so we are a tiny bit more
Expand Down Expand Up @@ -459,7 +459,7 @@ c99_env = env.Clone()
c99_env.Append(CFLAGS=['-std=c99'])
# VLA test is broken on nacl-gcc x86-64 (segfaults in test_two_recursion()).
# http://code.google.com/p/nativeclient/issues/detail?id=3527
vla_is_broken = not env.Bit('bitcode') and env.Bit('build_x86_64')
vla_is_broken = not env.Bit('bitcode') and env.Bit('build_x86_64') and not env.Bit('saigo')
nexe = c99_env.ComponentProgram('vla', 'vla.c',
EXTRA_LIBS=['${NONIRT_LIBS}'])
node = env.CommandSelLdrTestNacl('vla.out', nexe,
Expand Down
2 changes: 1 addition & 1 deletion tests/trusted_crash/crash_in_syscall/test_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *exc_info) {
* although the unsigned values are used in headers and are more
* widely recognised
*/
fprintf(stderr, "** intended_exit_status=%i\n", STATUS_ACCESS_VIOLATION);
fprintf(stderr, "** intended_exit_status=%u\n", STATUS_ACCESS_VIOLATION);
} else if (strcmp(g_crash_type, "NACL_TEST_CRASH_LOG_FATAL") == 0 ||
strcmp(g_crash_type, "NACL_TEST_CRASH_CHECK_FAILURE") == 0) {
fprintf(stderr, "** intended_exit_status=trusted_sigabrt\n");
Expand Down