-
Notifications
You must be signed in to change notification settings - Fork 423
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
[Bug]: extern records cannot have a different ordering of fields #26235
Labels
Comments
The spec text dates to when the C back-end was dominant, possibly even before the LLVM back-end existed. I wasn't aware that LLVM was sensitive to this until now. As to why llvm + gasnet works… we don't fall back to the C back-end in that configuration for some reason do we? (the only semi-plausible explanation I could come up with). |
jabraham17
added a commit
that referenced
this issue
Nov 21, 2024
Adds a new package module, `Python`, which supports calling Python code from Chapel. For example, the following Chapel progam use the python interface to `BeautifulSoup` to parse HTML ```chapel import Python; use URL; use List; proc main() { const url = 'https://chapel-lang.org/docs/main/language/spec/interoperability.html'; var htmlReader = openUrlReader(url); var html = htmlReader.readAll(string); var interp = new Python.Interpreter(); var mod = new Python.Module(interp, "bs4"); var cls = new Python.Class(mod, "BeautifulSoup"); var soup = cls(html, 'html.parser'); var res: list(owned Python.ClassObject?); res = soup.callMethod(res.type, "find_all", "h3"); for c in res { writeln(c!.getAttr(string, "text")); } } ``` As an another example, this simple program compiles an runs a Python lambda from Chapel code ```chapel import Python; config const n = 10; config const func = "lambda x,: x + 1 if x % 2 != 0 else x"; proc apply(interp: borrowed, type t, arr, l) { var lambdaFunc = new Python.Function(interp, l); var res: [arr.domain] t; for i in arr.domain { res(i) = lambdaFunc(t, arr(i)); } return res; } proc main() { var interp = new Python.Interpreter(); var data: [1..#n] int = 1..#n; writeln(" data: ", data); var res = apply(interp, int, data, func); writeln("res: ", res); } ``` Future work: - Convert classes to a hierarchy under `Value` so that more implementation can be shared and the Chapel interface can better imitate python - Add special support for common python types as sub-classes of value, to avoid round tripping values through chapel in many cases - Support common operators like add. These can be called today as dunder methods (`.call("__add__", ...)`), but it would be nice to support native operators like `+` - Add the ability to compile arbitrary chapel strings, beyond just lambdas - Setup python to use Chapel stdout/stderr - Add custom adapters for Chapel arrays to allow python functions to operate on Chapel arrays, without copying - Support python context managers as Chapel context managers - Fully support Python sets, Python dictionaries, Chapel sets, Chapel maps, Chapel associative arrays, and Chapel associative domains - Make sure all python objects are properly reference counted - Resolve TODO with LLVM IR verification: #26235 [Reviewed by @DanilaFe]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the spec on extern records, an extern record can specify fields in a differen't order than the actual struct definition.
From https://chapel-lang.org/docs/main/language/spec/interoperability.html#referring-to-external-c-structs-and-unions:
However, when using
CHPL_TARGET_COMPILER=llvm
with--verify
, this is not true.Given the following Chapel code:
And associated C code in
R.h
:Compiling this as
chpl --target-compiler=llvm --verify foo.chpl
fails with the followingHowever, using
--target-compiler=clang
compiles fine. This is also fine without--verify
Weirdly, using
--comm=gasnet
and--target-compiler=llvm
does work fine. So this only seems to be a problem withCHPL_COMM=none
andCHPL_TARGET_COMPILER=llvm
Failing chplenv:
Passing chplenv (using C backend):
Passing chplenv (using LLVM and gasnet)
The text was updated successfully, but these errors were encountered: