Skip to content

Commit 32ff5ee

Browse files
authored
Merge pull request #4 from tonybaloney/udpates
Redirection of microsoft#237
2 parents 2e4e648 + be8d595 commit 32ff5ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+8651
-9502
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake-build-*
2+
CoreCLR/artifacts
3+
.git
4+
CoreCLR/.git

.github/workflows/master.yml

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ master ]
88

99
env:
10-
BUILD_TYPE: Release
10+
BUILD_TYPE: Debug
1111

1212
jobs:
1313
build-linux:
@@ -17,10 +17,23 @@ jobs:
1717
python-version: [3.9]
1818
steps:
1919
- uses: actions/checkout@v2
20-
submodules: 'recursive'
20+
with:
21+
submodules: 'recursive'
22+
- name: Setup python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
architecture: x64
27+
- name: Install CLR requirements
28+
run: |
29+
sudo apt-get install -y cmake llvm-9 clang-9 autoconf automake \
30+
libtool build-essential python curl git lldb-6.0 liblldb-6.0-dev \
31+
libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev \
32+
libssl-dev libnuma-dev libkrb5-dev zlib1g-dev
2133
- uses: actions/setup-dotnet@v1
2234
with:
23-
dotnet-version: '5.0.100-rc.1.20452.10'
35+
dotnet-version: '5.0.100'
36+
2437
- name: Create Build Environment
2538
run: cmake -E make_directory ${{runner.workspace}}/build
2639

@@ -32,23 +45,37 @@ jobs:
3245
- name: Build
3346
working-directory: ${{runner.workspace}}/build
3447
shell: bash
35-
run: cmake --build . --config $BUILD_TYPE
48+
run: cmake --build . --config $BUILD_TYPE --target _pyjion
3649

37-
- name: Test
38-
working-directory: ${{runner.workspace}}/build
50+
- name: Build Python Package
51+
shell: bash
52+
run: pip install .
53+
54+
- name: Run smoke tests
55+
shell: bash
56+
run: python -X dev -q Tests/test_pyjion.py -f Tests/python_smoke_tests.txt -j1
57+
58+
- name: Run full test suite
3959
shell: bash
40-
run: ctest -C $BUILD_TYPE
60+
run: python -X dev -q Tests/test_pyjion.py -f Tests/python_tests.txt -j1
61+
4162
build-mac:
4263
runs-on: macos-latest
4364
strategy:
4465
matrix:
4566
python-version: [3.9]
4667
steps:
4768
- uses: actions/checkout@v2
48-
submodules: 'recursive'
69+
with:
70+
submodules: 'recursive'
71+
- name: Setup python
72+
uses: actions/setup-python@v2
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
architecture: x64
4976
- uses: actions/setup-dotnet@v1
5077
with:
51-
dotnet-version: '5.0.100-rc.1.20452.10'
78+
dotnet-version: '5.0.100'
5279
- name: Create Build Environment
5380
run: cmake -E make_directory ${{runner.workspace}}/build
5481

@@ -62,37 +89,74 @@ jobs:
6289
shell: bash
6390
run: cmake --build . --config $BUILD_TYPE
6491

65-
- name: Test
92+
- name: Build Python Package
93+
shell: bash
94+
run: pip install .
95+
96+
- name: Run unit tests
6697
working-directory: ${{runner.workspace}}/build
6798
shell: bash
68-
run: ctest -C $BUILD_TYPE
99+
run: ./unit_tests
100+
101+
- name: Run smoke tests
102+
shell: bash
103+
run: python -X dev Tests/test_pyjion.py -f Tests/python_smoke_tests.txt -j1
104+
105+
- name: Run full test suite
106+
shell: bash
107+
run: python -X dev -q Tests/test_pyjion.py -f Tests/python_tests.txt -j1
108+
69109
build-windows:
70110
runs-on: windows-latest
71111
strategy:
72112
matrix:
73113
python-version: [3.9]
74114
steps:
75-
- name: Add VC to path
76-
run: echo '::add-path::C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin'
77115
- uses: actions/checkout@v2
78-
submodules: 'recursive'
116+
with:
117+
submodules: 'recursive'
118+
- name: Setup python
119+
uses: actions/setup-python@v2
120+
with:
121+
python-version: ${{ matrix.python-version }}
122+
architecture: x64
123+
79124
- uses: actions/setup-dotnet@v1
80125
with:
81-
dotnet-version: '5.0.100-rc.1.20452.10'
126+
dotnet-version: '5.0.100'
127+
128+
- name: Add msbuild to PATH
129+
uses: microsoft/setup-msbuild@v1.0.2
130+
82131
- name: Create Build Environment
83132
run: cmake -E make_directory ${{runner.workspace}}/build
84133

85134
- name: Configure CMake
86135
shell: bash
87136
working-directory: ${{runner.workspace}}/build
88-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
137+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DDO_TESTS=1
89138

90139
- name: Build
91140
working-directory: ${{runner.workspace}}/build
92141
shell: bash
93-
run: cmake --build . --config $BUILD_TYPE
142+
run: cmake --build . --config Release
94143

95-
- name: Test
96-
working-directory: ${{runner.workspace}}/build
144+
- name: Install build deps
145+
shell: bash
146+
run: python -m pip install -U https://github.com/tonybaloney/scikit-build/archive/vs2019.zip
147+
148+
- name: Build Python Package
149+
shell: bash
150+
run: python setup.py build --generator "Visual Studio 16 2019"
151+
152+
- name: Install Python Package
153+
shell: bash
154+
run: python setup.py install --generator "Visual Studio 16 2019"
155+
156+
- name: Run smoke tests
157+
shell: bash
158+
run: python -X dev -q Tests/test_pyjion.py -f Tests/python_smoke_tests.txt -j1
159+
160+
- name: Run full test suite
97161
shell: bash
98-
run: ctest -C $BUILD_TYPE
162+
run: python -X dev -q Tests/test_pyjion.py -f Tests/python_tests_win.txt -j1

CMakeLists.txt

Lines changed: 109 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,60 @@ project(pyjion)
44
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55
set(CMAKE_C_STANDARD 11)
66
set(CMAKE_C_STANDARD_REQUIRED ON)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
9+
if (UNIX AND NOT APPLE)
10+
message(STATUS "Enabling PIC")
11+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
12+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
13+
endif()
714

815
find_package (Python3 3.9 COMPONENTS Interpreter Development)
16+
message(STATUS "Use Python libraries " ${Python3_LIBRARIES})
17+
if (SKBUILD)
18+
find_package(PythonExtensions REQUIRED)
19+
endif (SKBUILD)
20+
921
include_directories(${Python3_INCLUDE_DIRS})
1022

1123
set (CLR_DIR CoreCLR/src/coreclr)
1224

1325
add_definitions(-DUSE_STL)
1426

1527
IF(CMAKE_BUILD_TYPE MATCHES Debug)
16-
message(STATUS "Enabling very verbose messages")
28+
message(STATUS "Enabling verbose messages")
1729
add_definitions(-DDEBUG)
30+
set(DO_TESTS 1)
1831
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
1932

33+
if(DUMP_TRACES)
34+
message(STATUS "Enabling very-verbose messages")
35+
add_definitions(-DDUMP_TRACES)
36+
endif()
37+
38+
if(DUMP_JIT_TRACES)
39+
message(STATUS "Enabling very-very-verbose messages")
40+
add_definitions(-DDUMP_JIT_TRACES)
41+
endif()
42+
2043
if(NOT WIN32)
21-
set(CMAKE_CXX_STANDARD 14)
22-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
44+
set(CMAKE_CXX_STANDARD 17)
45+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
2346
include_directories(CoreCLR/src/coreclr/src/pal/inc/rt CoreCLR/src/coreclr/src/pal/inc CoreCLR/src/coreclr/src/pal/prebuilt/inc)
2447
add_compile_options(-DPAL_STDCPP_COMPAT)
25-
add_compile_options(-fdeclspec)
2648
add_compile_options(-fexceptions)
2749
add_compile_options(-fvisibility=hidden)
2850

2951
add_definitions(-DTARGET_UNIX)
3052
message(STATUS "Enabling UNIX Patches")
31-
add_compile_options(-Wswitch)
3253
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3354
add_compile_options(-Wno-null-arithmetic)
3455
else(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3556
add_compile_options(-Wno-conversion-null -Wno-pointer-arith)
3657
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3758
else()
38-
add_definitions(-DWINDOWS)
59+
add_definitions(-DWINDOWS=1)
60+
add_definitions(-D_HAS_STD_BYTE=0)
3961
if (MSVC)
4062
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
4163
endif(MSVC)
@@ -52,6 +74,8 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
5274
if (CMAKE_CL_64)
5375
set(IS_64 1)
5476
endif()
77+
else()
78+
message(STATUS "Don't recognise CPU arch " ${CMAKE_SYSTEM_PROCESSOR})
5579
endif()
5680

5781
if (IS_64)
@@ -68,58 +92,114 @@ if (IS_64)
6892
endif()
6993
else()
7094
add_definitions(-DTARGET_X86)
95+
add_definitions(-D_TARGET_X86_)
7196
message(STATUS "Enabling x86")
7297
endif()
7398

7499
include_directories(CoreCLR/src/coreclr/src/inc CoreCLR/src/coreclr/src/jit)
75100

101+
102+
103+
if (UNIX)
104+
if(DEFINED ENV{DOTNET_ROOT})
105+
file(GLOB DOTNETPATH $ENV{DOTNET_ROOT}/shared/Microsoft.NETCore.App*/5.0.0*/)
106+
else()
107+
file(GLOB DOTNETPATH /usr/local/share/dotnet/shared/Microsoft.NETCore.App*/5.0.0*/)
108+
endif()
109+
message(STATUS "Found .NET 5 in " ${DOTNETPATH})
110+
endif()
111+
76112
if (WIN32)
77113
set(CLR_OS_BUILD Windows_NT.x64.Debug)
78-
set(CLR_JIT_LIB "lib/coreclr_static.lib")
114+
if(DEFINED ENV{DOTNET_ROOT})
115+
file(GLOB DOTNETPATH $ENV{DOTNET_ROOT}/shared/Microsoft.NETCore.App*/5.0.0*/)
116+
else()
117+
file(GLOB DOTNETPATH $ENV{LOCALAPPDATA}/Microsoft/dotnet/shared/Microsoft.NETCore.App*/5.0.0*/)
118+
endif()
119+
message(STATUS "Found .NET 5 in " ${DOTNETPATH})
79120
endif()
80121

81-
if (LINUX)
122+
if (UNIX AND NOT APPLE)
82123
set(CLR_OS_BUILD Linux.x64.Debug)
83124
set(CLR_JIT_LIB "libclrjit.so")
125+
set(CLR_CMAKE_HOST_UNIX 1)
126+
add_definitions(-DFEATURE_SIMD)
127+
add_definitions(-DFEATURE_HW_INTRINSICS)
128+
add_compile_options(-fPIC)
84129
endif()
85130

86131
if (APPLE)
87132
set(CLR_OS_BUILD OSX.x64.Debug)
88-
include_directories(Pyjion/compat)
133+
include_directories(pyjion/compat)
89134
set(CLR_CMAKE_HOST_UNIX 1)
90135
set(CLR_JIT_LIB "libclrjit.dylib")
91136
add_definitions(-D_XOPEN_SOURCE)
92137
add_definitions(-DTARGET_OSX)
93-
138+
add_compile_options(-fdeclspec)
94139
add_definitions(-DFEATURE_SIMD)
95140
add_definitions(-DFEATURE_HW_INTRINSICS)
96141
endif()
97142

98-
include_directories(CoreCLR/artifacts/bin/coreclr/${CLR_OS_BUILD}/inc)
99-
set(SOURCES Pyjion/absint.cpp Pyjion/absvalue.cpp Pyjion/intrins.cpp Pyjion/jitinit.cpp Pyjion/pycomp.cpp Pyjion/pyjit.cpp Pyjion/disasm.cpp)
143+
if(NET_SRC_LIB) # use the libraries compiled from source
144+
set(DOTNETPATH ${CMAKE_SOURCE_DIR}/CoreCLR/artifacts/bin/coreclr/${CLR_OS_BUILD})
145+
endif()
146+
147+
set(SOURCES pyjion/absint.cpp pyjion/absvalue.cpp pyjion/intrins.cpp pyjion/jitinit.cpp pyjion/pycomp.cpp pyjion/pyjit.cpp pyjion/exceptionhandling.cpp pyjion/stack.cpp pyjion/block.cpp)
148+
149+
if (WIN32)
150+
enable_language(ASM_MASM)
151+
if (IS_64)
152+
set(HOST_ASM_MASM_X86_64 true)
153+
endif()
154+
set(SOURCES ${SOURCES} pyjion/helpers.asm)
155+
endif()
100156

101157
add_library(pyjionlib OBJECT ${SOURCES})
102-
add_library(pyjion MODULE $<TARGET_OBJECTS:pyjionlib>)
103-
install(TARGETS pyjion
104-
LIBRARY DESTINATION ${CMAKE_BINARY_DIR})
158+
add_library(_pyjion MODULE $<TARGET_OBJECTS:pyjionlib>)
159+
160+
if (WIN32)
161+
add_custom_command(
162+
TARGET _pyjion POST_BUILD
163+
COMMAND ${CMAKE_COMMAND} -E copy
164+
${DOTNETPATH}/clrjit.dll
165+
${CMAKE_CURRENT_BINARY_DIR}/clrjit.dll
166+
)
167+
endif(WIN32)
105168

106169
set_target_properties(
107-
pyjion
170+
_pyjion
108171
PROPERTIES
109172
PREFIX ""
110-
OUTPUT_NAME "pyjion"
173+
OUTPUT_NAME "_pyjion"
111174
LINKER_LANGUAGE C
112175
)
113176

114-
target_link_libraries(pyjion ${Python3_LIBRARIES})
115-
target_link_libraries(pyjion ${CMAKE_SOURCE_DIR}/CoreCLR/artifacts/bin/coreclr/${CLR_OS_BUILD}/${CLR_JIT_LIB})
116-
117-
# Testing
118-
add_subdirectory(Tests/Catch)
119-
set(TEST_SOURCES Tests/testing_util.cpp Tests/test_emission.cpp Tests/test_inference.cpp Tests/test_compiler.cpp Tests/test_absint.cpp Tests/Tests.cpp)
120-
add_executable(unit_tests ${TEST_SOURCES} $<TARGET_OBJECTS:pyjionlib>)
121-
target_compile_definitions(unit_tests PUBLIC -DDUMP_TRACES)
122-
target_include_directories(unit_tests PRIVATE Pyjion)
123-
target_link_libraries(unit_tests Catch2::Catch2)
124-
target_link_libraries(unit_tests ${Python3_LIBRARIES})
125-
target_link_libraries(unit_tests ${CMAKE_SOURCE_DIR}/CoreCLR/artifacts/bin/coreclr/${CLR_OS_BUILD}/${CLR_JIT_LIB})
177+
target_link_libraries(_pyjion ${Python3_LIBRARIES})
178+
179+
if (DO_TESTS)
180+
# Testing
181+
add_subdirectory(Tests/Catch)
182+
set(TEST_SOURCES Tests/testing_util.cpp Tests/test_emission.cpp Tests/test_compiler.cpp Tests/test_absint.cpp Tests/Tests.cpp Tests/test_wrappers.cpp Tests/test_exceptions.cpp Tests/test_scopes.cpp)
183+
add_executable(unit_tests ${TEST_SOURCES} $<TARGET_OBJECTS:pyjionlib>)
184+
if (NOT WIN32)
185+
set_property(TARGET unit_tests PROPERTY CXX_STANDARD 17)
186+
set_property(TARGET unit_tests PROPERTY CXX_EXTENSIONS OFF)
187+
endif(NOT WIN32)
188+
target_include_directories(unit_tests PRIVATE pyjion)
189+
target_link_libraries(unit_tests Catch2::Catch2)
190+
target_link_libraries(unit_tests ${Python3_LIBRARIES})
191+
192+
if (NOT WIN32)
193+
target_link_libraries(unit_tests ${DOTNETPATH}/${CLR_JIT_LIB})
194+
endif()
195+
endif(DO_TESTS)
196+
197+
if (NOT WIN32)
198+
target_link_libraries(_pyjion ${DOTNETPATH}/${CLR_JIT_LIB})
199+
endif()
200+
201+
if (SKBUILD)
202+
python_extension_module(_pyjion)
203+
endif (SKBUILD)
204+
205+
install(TARGETS _pyjion LIBRARY DESTINATION pyjion)

0 commit comments

Comments
 (0)