Skip to content
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

Allow yk to be consumed like a normal Rust dependency. #227

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

vext01
Copy link
Contributor

@vext01 vext01 commented Feb 9, 2021

For the cargo build target, we can make build.rs recursively run
cargo build in the internal workspace and then symlink libykshim.so
into the consumer's target directory. This avoids the need for consumers
to have special build logic.

We have to keep xtask around for running other targets
(test/fmt/...) recursively on both workspaces. I had hoped to have
build.rs do this automatically too, but we would need to know which
target has been requested and this information isn't exposed to
build.rs.

Tested with ykbf, which can now be built with simply:

RUSTFLAGS="-C tracer=hw" cargo build

Whereas previous attempts had tried using complicated wrapper scripts,
which each consumer in turn would need to duplicate.

@ptersilie
Copy link
Contributor

ptersilie commented Feb 9, 2021

RUSTFLAGS="-C tracer=hw" cargo build

At the moment I don't seem to require RUSTFLAGS. Is this now needed again? Could be not add this flag to the build.rs too, so we can just do cargo build, similar to how now I just do cargo xtask build?

ykrt/build.rs Outdated Show resolved Hide resolved
ykrt/build.rs Outdated Show resolved Hide resolved
@vext01
Copy link
Contributor Author

vext01 commented Feb 9, 2021

At the moment I don't seem to require RUSTFLAGS. Is this now needed again? Could be not add this flag to the build.rs too

Afraid we need to specify this again. build.rs doesn't allow adding of arbitrary rust flags.

README.md Outdated
This repo uses xtask instead of regular cargo, so instead of running `cargo
<target>`, you will instead need to execute `cargo xtask <target>`.
This repo contains two separately-compiled workspaces, and thus the build
system is a little non-standard. To act recursively on both workspaces, instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this talk about "recursion" seems to me like an implementation detail that isn't of much importance to whoever indents to use/build this. Should we simplify these descriptions by removing any mention to recursion and just say something like: "To build both workspaces, use cargo xtask target instead of cargo target."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did start with something like that, but I thought people would ask "so how comes it works when I consume yk? Dependencies can't run xtask!".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why anyone would ask this. The README says this is how you build it so that's what you have to do. ;-) And if they are still interested they can go read the code and its comment. My worry is that it's more likely to confuse people reading the README about what any of this means and why they should know about it, if all they want to do is build the thing.

README.md Outdated Show resolved Hide resolved
xtask/Cargo.toml Outdated Show resolved Hide resolved
ykrt/build.rs Outdated Show resolved Hide resolved
ykrt/build.rs Outdated Show resolved Hide resolved
@vext01
Copy link
Contributor Author

vext01 commented Feb 9, 2021

I think this addresses all review comments.

This repo contains two separately-compiled workspaces, and thus the build
system is a little non-standard. To act recursively on both workspaces, instead
of running `cargo <target>`, instead execute `cargo xtask <target>`.
To work with this repository, instead of running `cargo <target>`, instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you say offline that you need to use cargo build without xtask if you just want to build? Or can I just always use xtask in either case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do either, but it's simpler to say "always use xtask".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

system is a little non-standard. To act recursively on both workspaces, instead
of running `cargo <target>`, instead execute `cargo xtask <target>`.
To work with this repository, instead of running `cargo <target>`, instead
execute `cargo xtask <target>`.

You will also need to add the `-C tracer=<kind>` flag to `RUSTFLAGS` to tell
the build system what kind of tracer you want to use (`hw` or `sw`, although
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a mention of recursively below.

@vext01
Copy link
Contributor Author

vext01 commented Feb 9, 2021

Try this.

@ptersilie
Copy link
Contributor

If @bjorn3 is happy, please squash.

For the `cargo build` target, we can make `build.rs` recursively run
`cargo build` in the internal workspace and then symlink `libykshim.so`
into the consumer's target directory. This avoids the need for consumers
to have special build logic.

We have to keep xtask around for running other targets
(`test`/`fmt`/...) recursively on both workspaces. I had hoped to have
`build.rs` do this automatically too, but we would need to know which
target has been requested and this information isn't exposed to
`build.rs`.

Tested with `ykbf`, which can now be built with simply:
```
RUSTFLAGS="-C tracer=hw" cargo build
```

Whereas previous attempts had tried using complicated wrapper scripts,
which each consumer in turn would need to duplicate.
@vext01
Copy link
Contributor Author

vext01 commented Feb 9, 2021

Splat.

@ptersilie
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 9, 2021

Build succeeded:

@bors bors bot merged commit 19da1fa into ykjit:master Feb 9, 2021
@vext01 vext01 deleted the build-sys-again branch February 9, 2021 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants