Skip to content

Commit 6301831

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
More windows exclusions
Summary: Excludes more stuff from building on Windows that doesn't work. Reviewed By: alexmalyshev Differential Revision: D92345941 fbshipit-source-id: a035f09238f5422e6bd847dda7aaf5603c4bc1ab
1 parent 8862138 commit 6301831

9 files changed

Lines changed: 59 additions & 7 deletions

File tree

cinderx/Jit/context.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
#include "cinderx/module_state.h"
1313
#include "cinderx/python_runtime.h"
1414

15-
#include <sys/mman.h>
16-
1715
#ifndef WIN32
1816
#include <dlfcn.h>
17+
#include <sys/mman.h>
1918
#endif
2019

2120
namespace jit {
@@ -127,12 +126,14 @@ Context::Context()
127126
}
128127

129128
void Context::mlockProfilerDependencies() {
129+
#ifndef WIN32
130130
for (auto& codert : code_runtimes_) {
131131
PyCodeObject* code = codert.frameState()->code().get();
132132
::mlock(code, sizeof(PyCodeObject));
133133
::mlock(code->co_qualname, Py_SIZE(code->co_qualname));
134134
}
135135
code_runtimes_.mlock();
136+
#endif
136137
}
137138

138139
Ref<> Context::pageInProfilerDependencies() {

cinderx/Jit/hir/preload.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static void fill_primitive_arg_types_builtin(
8383
}
8484
}
8585

86+
#ifndef WIN32
8687
static std::unique_ptr<NativeTarget> resolve_native_target(
8788
BorrowedRef<> native_descr,
8889
BorrowedRef<> signature) {
@@ -117,6 +118,7 @@ static std::unique_ptr<NativeTarget> resolve_native_target(
117118

118119
return target;
119120
}
121+
#endif
120122

121123
PreloaderManager s_manager;
122124
thread_local PreloaderManager* tls_manager = nullptr;
@@ -409,13 +411,15 @@ bool Preloader::preload() {
409411
return false;
410412
}
411413
}
414+
#ifndef WIN32
412415
case INVOKE_NATIVE: {
413416
BorrowedRef<> target_descr = PyTuple_GetItem(constArg(bc_instr), 0);
414417
BorrowedRef<> signature = PyTuple_GetItem(constArg(bc_instr), 1);
415418
native_targets_.emplace(
416419
target_descr, resolve_native_target(target_descr, signature));
417420
break;
418421
}
422+
#endif
419423
}
420424
}
421425

cinderx/Jit/mmap_file.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "cinderx/Common/util.h"
66

7+
#ifndef WIN32
78
#include <fcntl.h>
89
#include <fmt/format.h>
910
#include <sys/mman.h>
@@ -92,3 +93,5 @@ std::span<const std::byte> MmapFile::data() {
9293
}
9394

9495
} // namespace jit
96+
97+
#endif

cinderx/Jit/mmap_file.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace jit {
99

10+
#ifndef WIN32
1011
class MmapFile {
1112
public:
1213
constexpr MmapFile() = default;
@@ -24,4 +25,6 @@ class MmapFile {
2425
size_t size_{0};
2526
};
2627

28+
#endif
29+
2730
} // namespace jit

cinderx/Jit/perf_jitdump.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "cinderx/Jit/config.h"
1212
#include "cinderx/Jit/threaded_compile.h"
1313

14+
#ifndef WIN32
15+
1416
#include <fmt/format.h>
1517
#include <sys/file.h>
1618
#include <sys/mman.h>
@@ -39,8 +41,11 @@
3941
#define EM_X86_64 62
4042
#define EM_AARCH64 183
4143

44+
#endif
45+
4246
namespace jit::perf {
4347

48+
#ifndef WIN32
4449
int jit_perfmap = 0;
4550
std::string perf_jitdump_dir;
4651

@@ -479,14 +484,21 @@ void copyJitdumpFile() {
479484

480485
} // namespace
481486

487+
#endif
488+
482489
bool isPreforkCompilationEnabled() {
490+
#ifndef WIN32
483491
return getConfig().compile_perf_trampoline_prefork;
492+
#else
493+
return false;
494+
#endif
484495
}
485496

486497
void registerFunction(
487498
const std::vector<std::pair<void*, std::size_t>>& code_sections,
488499
std::string_view name,
489500
std::string_view prefix) {
501+
#ifndef WIN32
490502
ThreadedCompileSerialize guard;
491503

492504
initFiles();
@@ -526,14 +538,17 @@ void registerFunction(
526538
}
527539
std::fflush(file);
528540
}
541+
#endif
529542
}
530543

531544
void afterForkChild() {
545+
#ifndef WIN32
532546
// Make sure the parent processes map is closed before copying into it,
533547
// otherwise init is a nop.
534548
PyUnstable_PerfMapState_Fini();
535549
copyParentPidMap();
536550
copyJitdumpFile();
551+
#endif
537552
}
538553

539554
} // namespace jit::perf

cinderx/Jit/pyjit.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
#include "cinderx/Shadowcode/shadowcode.h"
4747
#include "cinderx/module_state.h"
4848

49+
#ifndef WIN32
4950
#include <dlfcn.h>
51+
#endif
5052
#include <fmt/std.h>
5153

5254
#include <atomic>
@@ -695,6 +697,7 @@ FlagProcessor initFlagProcessor() {
695697
"Add RefineType instructions to coerce Static Python types to be "
696698
"valid");
697699

700+
#ifndef WIN32
698701
flag_processor.addOption(
699702
"jit-perfmap",
700703
"JIT_PERFMAP",
@@ -709,6 +712,7 @@ FlagProcessor initFlagProcessor() {
709712
"absolute path to a <DIRECTORY> that exists. A perf jitdump file "
710713
"will be written to this directory")
711714
.withFlagParamName("DIRECTORY");
715+
#endif
712716

713717
flag_processor.addOption(
714718
"jit-help", "", [] {}, "print all available JIT flags and exits");
@@ -1732,6 +1736,7 @@ int aot_func_visitor(PyObject* obj, void* arg) {
17321736
return kGcVisitContinue;
17331737
}
17341738

1739+
#ifndef WIN32
17351740
PyObject* load_aot_bundle(PyObject* /* self */, PyObject* arg) {
17361741
JIT_CHECK(
17371742
jitCtx() != nullptr,
@@ -1796,6 +1801,7 @@ PyObject* load_aot_bundle(PyObject* /* self */, PyObject* arg) {
17961801

17971802
Py_RETURN_NONE;
17981803
}
1804+
#endif
17991805

18001806
PyObject* get_compile_after_n_calls(PyObject* /* self */, PyObject*) {
18011807
auto limit = getConfig().compile_after_n_calls;
@@ -1878,6 +1884,7 @@ PyObject* disassemble(PyObject* /* self */, PyObject* func) {
18781884
Py_RETURN_NONE;
18791885
}
18801886

1887+
#ifndef WIN32
18811888
PyObject* dump_elf(PyObject* /* self */, PyObject* arg) {
18821889
JIT_CHECK(
18831890
jitCtx() != nullptr,
@@ -1916,6 +1923,7 @@ PyObject* dump_elf(PyObject* /* self */, PyObject* arg) {
19161923

19171924
Py_RETURN_NONE;
19181925
}
1926+
#endif
19191927

19201928
PyObject* get_jit_list(PyObject* /* self */, PyObject*) {
19211929
if (auto jit_list = cinderx::getModuleState()->jitList()) {
@@ -2773,6 +2781,7 @@ PyMethodDef jit_methods[] = {
27732781
"Configure the JIT to automatically compile functions after "
27742782
"they are called a set number of times.")},
27752783
{"disassemble", disassemble, METH_O, "Disassemble JIT compiled functions."},
2784+
#ifndef WIN32
27762785
{"dump_elf",
27772786
dump_elf,
27782787
METH_O,
@@ -2788,6 +2797,7 @@ PyMethodDef jit_methods[] = {
27882797
"file, whose filepath is passed as the first argument. Note: "
27892798
"This does not actually work yet, it's being used for debugging "
27902799
"purposes.")},
2800+
#endif
27912801
{"get_compile_after_n_calls",
27922802
get_compile_after_n_calls,
27932803
METH_NOARGS,
@@ -3576,7 +3586,9 @@ void finalize() {
35763586
mod_state->setJitContext(nullptr);
35773587
mod_state->setCodeAllocator(nullptr);
35783588

3589+
#ifndef WIN32
35793590
g_aot_ctx.destroy();
3591+
#endif
35803592

35813593
restoreSysMonitoringRegisterCallback();
35823594
restoreSysSetProfileAndSetTrace();

cinderx/Jit/symbolizer.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
#include "cinderx/Common/util.h"
77
#include "cinderx/module_state.h"
88

9+
#ifndef WIN32
10+
911
#include <cxxabi.h>
10-
#include <dlfcn.h>
12+
13+
#endif
1114

1215
#ifdef ENABLE_SYMBOLIZER
16+
17+
#include <dlfcn.h>
1318
#include <elf.h>
1419
#include <link.h> // for ElfW
20+
1521
#endif
1622

1723
#include <cstdio>
@@ -128,14 +134,14 @@ int findSymbolIn(struct dl_phdr_info* info, size_t, void* data) {
128134
} // namespace
129135

130136
Symbolizer::Symbolizer(const char* exe_path) {
137+
#ifdef ENABLE_SYMBOLIZER
131138
try {
132139
file_.open(exe_path);
133140
} catch (const std::exception& exn) {
134141
JIT_LOG("{}", exn.what());
135142
return;
136143
}
137144

138-
#ifdef ENABLE_SYMBOLIZER
139145
const std::byte* exe = file_.data().data();
140146

141147
auto elf = reinterpret_cast<const ElfW(Ehdr)*>(exe);
@@ -229,6 +235,7 @@ void Symbolizer::deinit() {
229235
}
230236

231237
std::optional<std::string> demangle(const std::string& mangled_name) {
238+
#ifndef WIN32
232239
int status;
233240
char* demangled_name =
234241
abi::__cxa_demangle(mangled_name.c_str(), nullptr, nullptr, &status);
@@ -248,6 +255,9 @@ std::optional<std::string> demangle(const std::string& mangled_name) {
248255
std::string result{demangled_name};
249256
std::free(demangled_name);
250257
return result;
258+
#else
259+
return std::nullopt;
260+
#endif
251261
}
252262

253263
std::optional<std::string> symbolize(const void* func) {

cinderx/Jit/symbolizer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
#include "cinderx/Jit/mmap_file.h"
66
#include "cinderx/Jit/symbolizer_iface.h"
77

8-
#include <fcntl.h>
98
#ifndef WIN32
9+
#include <fcntl.h>
1010
#include <sys/mman.h>
11-
#include <unistd.h>
12-
#endif
1311
#include <sys/stat.h>
1412
#include <sys/types.h>
13+
#include <unistd.h>
1514

1615
#include <optional>
1716
#include <string>
@@ -61,3 +60,4 @@ std::optional<std::string> demangle(const std::string& mangled_name);
6160
std::optional<std::string> symbolize(const void* func);
6261

6362
} // namespace jit
63+
#endif

cinderx/StaticPython/_static.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,7 @@ PyObject* resolve_primitive_descr(PyObject* mod, PyObject* descr) {
16751675
return PyLong_FromLong(type_code);
16761676
}
16771677

1678+
#ifndef WIN32
16781679
static PyObject* lookup_native_symbol(
16791680
PyObject* Py_UNUSED(module),
16801681
PyObject** args,
@@ -1710,6 +1711,7 @@ PyObject* clear_dlsym_cache(PyObject* Py_UNUSED(module)) {
17101711
_PyClassloader_Clear_DlSym_Cache();
17111712
Py_RETURN_NONE;
17121713
}
1714+
#endif
17131715

17141716
static int sp_audit_hook(const char* event, PyObject* args, void* data) {
17151717
if (strcmp(event, "object.__setattr__") != 0 || PyTuple_GET_SIZE(args) != 3) {
@@ -1839,6 +1841,7 @@ static PyMethodDef static_methods[] = {
18391841
METH_FASTCALL,
18401842
""},
18411843
{"init_subclass", (PyCFunction)init_subclass, METH_O, ""},
1844+
#ifndef WIN32
18421845
{"lookup_native_symbol",
18431846
(PyCFunction)(void (*)(void))lookup_native_symbol,
18441847
METH_FASTCALL,
@@ -1859,6 +1862,7 @@ static PyMethodDef static_methods[] = {
18591862
(PyCFunction)(void (*)(void))clear_dlsym_cache,
18601863
METH_FASTCALL,
18611864
""},
1865+
#endif
18621866
{"install_sp_audit_hook",
18631867
(PyCFunction)(void (*)(void))install_sp_audit_hook,
18641868
METH_NOARGS,

0 commit comments

Comments
 (0)