Skip to content

Link stdc++ #1139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 11, 2020
Merged
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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def _build_monoclr(self):
# build the clr python module
clr_ext = Extension(
"clr",
language="c++",
sources=["src/monoclr/pynetinit.c", "src/monoclr/clrmod.c"],
extra_compile_args=cflags.split(" "),
extra_link_args=libs.split(" "),
Expand Down
8 changes: 8 additions & 0 deletions src/monoclr/pynetclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#define MONO_DOMAIN "Python.Runtime"
#define PR_ASSEMBLY "Python.Runtime.dll"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct
{
MonoDomain *domain;
Expand All @@ -29,4 +33,8 @@ void PyNet_Finalize(PyNet_Args *);
void main_thread_handler(PyNet_Args *user_data);
char *PyNet_ExceptionToString(MonoObject *);

#ifdef __cplusplus
}
#endif

#endif // PYNET_CLR_H
11 changes: 10 additions & 1 deletion src/monoclr/pynetinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ PyNet_Args *PyNet_Init(int ext)
pn_args->shutdown = NULL;
pn_args->module = NULL;

#ifdef __linux__
// Force preload libmono-2.0 as global. Without this, on some systems
// symbols from libmono are not found by libmononative (which implements
// some of the System.* namespaces). Since the only happened on Linux so
// far, we hardcode the library name, load the symbols into the global
// namespace and leak the handle.
dlopen("libmono-2.0.so", RTLD_LAZY | RTLD_GLOBAL);
#endif

if (ext == 0)
{
pn_args->init_name = "Python.Runtime:Initialize()";
Expand Down Expand Up @@ -122,7 +131,7 @@ void main_thread_handler(PyNet_Args *user_data)
strcpy(new_ld_library_path, py_libdir);
strcat(new_ld_library_path, ":");
strcat(new_ld_library_path, ld_library_path);
setenv("LD_LIBRARY_PATH", py_libdir, 1);
setenv("LD_LIBRARY_PATH", new_ld_library_path, 1);
}
}

Expand Down
4 changes: 3 additions & 1 deletion tools/geninterop/geninterop.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def preprocess_python_headers():
include_py = sysconfig.get_config_var("INCLUDEPY")
include_dirs.append(include_py)

include_args = [c for p in include_dirs for c in ["-I", p]]

defines = [
"-D", "__attribute__(x)=",
"-D", "__inline__=inline",
Expand All @@ -198,7 +200,7 @@ def preprocess_python_headers():
defines.extend(("-D", "PYTHON_WITH_WIDE_UNICODE"))

python_h = os.path.join(include_py, "Python.h")
cmd = ["clang", "-pthread", "-I"] + include_dirs + defines + ["-E", python_h]
cmd = ["clang", "-pthread"] + include_args + defines + ["-E", python_h]

# normalize as the parser doesn't like windows line endings.
lines = []
Expand Down