-
Notifications
You must be signed in to change notification settings - Fork 165
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
Borrowck: Polonius FFI #2716
Borrowck: Polonius FFI #2716
Conversation
4129af8
to
2cf9912
Compare
To solve:
|
6fa6aa2
to
9b8581e
Compare
ChangeLog: * .github/workflows/ccpp.yml: Install cargo. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
9b8581e
to
2f89ed0
Compare
I have added cargo install to GH actions. |
We should at least ensure it is available during configuration. |
rust/libffi_polonius.a: \ | ||
rust/checks/errors/borrowck/ffi-polonius/Cargo.toml \ | ||
$(wildcard $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/src/*) | ||
cargo build --manifest-path $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml --release --target-dir rust/ffi-polonius |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that requiring cargo
as part of GCC/Rust build process is not exactly what upstream GCC was looking for... 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, there is not simply a shared library to link against, or executable to call (at GCC/Rust
invocation time)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, cargo
is "just" a build tool -- so assumingly we can get FFI-Polonius built in another "standard" (for GCC practices) way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to compile polonius with gccrs, which probably won't be possible for a long time. But in the long run it would probably be better to remove this dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably use direct rustc
invocation instead of using cargo
. The current polonius-engine
only has 3 deps:
polonius-engine v0.13.
├── datafrog v2.0.1
├── log v0.4.14
│ └── cfg-if v1.0.0
└── rustc-hash v1.1.0
but this doesn't scale very well if more dependencies are added. Would having a dep on rustc
to build gccrs something we want in GCC until gccrs can build polonius? If not, then this can stay in gccrs tree (for a long time...).
Is there already a plan for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably use direct
rustc
invocation instead of usingcargo
. The currentpolonius-engine
only has 3 deps:polonius-engine v0.13. ├── datafrog v2.0.1 ├── log v0.4.14 │ └── cfg-if v1.0.0 └── rustc-hash v1.1.0
but this doesn't scale very well if more dependencies are added. Would having a dep on
rustc
to build gccrs something we want in GCC until gccrs can build polonius? If not, then this can stay in gccrs tree (for a long time...).Is there already a plan for this?
Do you really think using plain rustc
is better for the gcc folks? (I would feel somewhat ashamed to build Rust with make 😢, but it is not really important here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have no idea. I feel like this change won't hit upstream gcc until...some time. So whatever is best for you, but this needs to not get in the way of upstreaming the rest of the compiler. If that's the plan (we commit things we know are not fit for upstream gcc), then you should probably have separate commits for changes that will be upstreamed and the changes that we know won't ever reach gcc in this state. Meaning that some code in GCC would be unused until we can build with gccrs
and enable the build...?
If you start requiring rustc
/cargo
, you'll break all platforms that are not supported by rustc
(exit sh-*
, s390x-*
, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I clearly wasn't really awake yet, when posting my comments yesterday Monday morning...
requiring cargo in not really worse then rustc
Point taken. ;-)
compile polonius with gccrs
That also won't solve all problems immediately, given that we need Polonius compiled for the host architecture (in order to link it into GCC), and build, host, target architectures may all be different. So we cannot rely on being able to use the GCC/Rust being built (for the target architecture) for building any Rust code for host usage. (Building for target is fine, of course, like other GCC target libraries.)
A multi-stage build process would resolve that issue; either manual or even scripted into the GCC's top-level build system (non-trivial).
My original assumption was:
So, there is not simply a shared library to link against, or executable to call (at GCC/Rust invocation time)?
I agree to what Marc just said:
whatever is best for you, but this needs to not get in the way of upstreaming the rest of the compiler
..., so we have to make use of Polonius conditional on its availability; and otherwise continue to require -frust-incomplete-and-experimental-compiler-do-not-use
being specified, for instance.
Such a GCC/Rust mode generally will be necessary to continue supporting GCC/Rust in configurations where standard Rust is not available, and thus Polonius cannot be built at all, currently. (Standard bootstrapping problem.) ..., unless Polonius can be cross-compiled for the respective host architecture, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compile polonius with gccrs
That also won't solve all problems immediately, given that we need Polonius compiled for the host architecture (in order to link it into GCC), and build, host, target architectures may all be different. So we cannot rely on being able to use the GCC/Rust being built (for the target architecture) for building any Rust code for host usage. (Building for target is fine, of course, like other GCC target libraries.)
Kind of similar issue with proc macros that need to be compiled for host (but not only during the build of gcc)
If you start requiring
rustc
/cargo
, you'll break all platforms that are not supported byrustc
(exitsh-*
,s390x-*
, ...)
Not 100% correct, only where rustc
is not available for host, not target (e.g. sh
is usually cross compiled, so rustc
doesn't need to be available for the sh
target)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could ffi-polonius
be loaded as a shared library by gccrs
during compilation? That way it could be kept out of tree for now.
Btw could anyone help me with the gcc4.8. It builds on my machine and I am not sure what is wrong there with pthreads linking (different then elsewhere)? |
2f89ed0
to
8a2dd90
Compare
Possibly in the old system, pthreads symbols are still in a separate library, before that was all moved into libc (in the glibc context -- may still be separate on other architectures), and thus Generally there should be a way to query |
3a0d489
to
b34dd80
Compare
gcc/rust/ChangeLog: * Make-lang.in: Build FFI-Polonius. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Invoke Polonius. * checks/errors/borrowck/ffi-polonius/Cargo.toml: New file. * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: New file. * checks/errors/borrowck/ffi-polonius/src/lib.rs: New file. * checks/errors/borrowck/polonius/rust-polonius-ffi.h: New file. * checks/errors/borrowck/polonius/rust-polonius.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
b34dd80
to
b87f621
Compare
I don't see why not.
…On Thu, 2 Nov 2023, at 23:06, Owen Avery wrote:
***@***.**** commented on this pull request.
In gcc/rust/Make-lang.in <#2716 (comment)>:
> @@ -461,3 +464,9 @@ rust/%.o: rust/checks/errors/borrowck/%.cc
rust/%.o: rust/metadata/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
+
+rust/libffi_polonius.a: \
+ rust/checks/errors/borrowck/ffi-polonius/Cargo.toml \
+ $(wildcard $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/src/*)
+ cargo build --manifest-path $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml --release --target-dir rust/ffi-polonius
Could polonius be loaded as a shared library by the compiler? The actual implementation, as opposed to the bindings, could be kept out-of-tree for now.
—
Reply to this email directly, view it on GitHub <#2716 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AFNB76E4M7H4RQPWGILTUADYCQKNDAVCNFSM6AAAAAA6U67LSGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMJRGMYTKMJTG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Replaced with #2889 |
FFI gccrs -> Polonius and build of Polonius (via FFI-Polonius bindigs) with gcc build system.
Cargo supports
--outdir
to copy final library to, which would be nice here, but right now it is unstable. :(@CohenArthur
@tschwinge Is the clean alright? Should we somehow use autoconf to find cargo? Should/can we pass down the the information whether debug symbols are to be created to Rust?