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

Shaderc-rs & Shaderc-sys split #46

Merged
merged 12 commits into from
Apr 22, 2019
Merged

Conversation

knappador
Copy link
Contributor

@knappador knappador commented Mar 30, 2019

--snip-- #44 has almost all of the discussion leading up to the merge commit notes

fixes #44

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@knappador
Copy link
Contributor Author

I signed it!
@googlebot

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Version 0.4.0 has been skipped and tag will not be used.  History for a prospective split at 0.4.0 into two repos has been obliterated.

Internal renaming in shaderc-rs/src/lib.rs ffi -> scs

The crates were split as follows:

Sys crate files
- Build dependencies
- build.rs
- ffi.rs
Rs crate files
- lib.rs
Top level
- contrib agreement
- .gitmodules
- .gitignore
- workspace Cargo.toml
- CI scripts
- license
- readme
- `check-passthrough` must be enabled on the sys dependency to even allow setting the old `--no-defaults` behavior
- `dont-use-deprecated` feature of the sys package allows suppression of old `--no-defaults` to be set as a default in the rs package
- `dont-use-deprecated` must be **disabled** by passing `--no-defaults` to rs package to enable the old `--no-defaults` behavior in sys

The old use of --no-default-features applies to shaderc-rs, but now it needs to be passed through to shaderc-sys.  This is done by passing an inverted flag to suppress the behavior by default from shaderc-rs.  When the suppression is removed with --no-default-features, the old behavior is re-enabled and shaderc-sys looks for a libshaderc_combined.a in the out directory

When building shaderc-sys directly, only check for the passthrough flag if it could be enabled.  It's a package opt-in deprecated behavior.  It definitely needs deprecation.
@knappador
Copy link
Contributor Author

@antiagainst I'm not sure what's up on the Appveyor results. I have little visibility outside of Arch Linux so far.

This PR should read fine as a series of independent commits.

Re-implemented the --no-defaults behavior
Added more robust build options & behavior

I primarily used this heavily referenced guide to writing sys crates to select what traditions to try to follow. The one area I'm not yet 100% clear on is overriding the static library location using a downstream project's Cargo.toml

To quickly run through a thorough test of the Linux build paths on Arch linux:

cargo test
cargo clean
cargo test --features build-from-source
cp ../target/debug/../libshaderc_combined.a .
cargo clean
cargo test SHADERC_STATIC=./libshaderc_combined.a
cargo clean
cargo test --features check-passthrough  # will cause trigger old --no-defaults behavior on sys crate
# cp the library into the specified location
# re-run with --features check-passthrough
cargo clean
mkdir libs
cp /usr/lib/libshaderc_combined.a libs/
cp /usr/lib/libglslang.a libs/
cp /usr/lib/libSPIRV.a libs/
cp /usr/lib/libSPIRV-Tools.a libs/
cargo test SHADERC_STATIC=./libs/

Happy to punch some commits into working on Appveyor but I'll need some information.

@knappador
Copy link
Contributor Author

Handling the merge issue. Tests for shaderc-rs fail due to linking. I'm incorporating 367a4dd as well, which won't apply at all.

Might punch some more history later to convert the delete to a move if possible.

If you are here because your windows or macos builds are breaking, I apologize.  The changes were not developed on these platforms.  You will have to research older versions of the crate to establish whether they were in a "just works" state and if not, research your relevant platform options and make it work.

This commit implements several new build behaviors:

- Building libshaderc from source is now fallback behavior on Linux
- Linux will check "/usr/lib/" for libraries by default
- SPIRV and glslang libraries _may_ be picked up correctly if they exist in the same location as libshaderc, but funky combinations could break
- Specification of a static library via SHADERC_STATIC, SHADERC_LIB_DIR, or SHADERC_LIB_PATH instead of the hacky --no-default-options
- tests will build correctly when using hacky --no-default-options paths (stdc was not being included)
@knappador
Copy link
Contributor Author

Full test sequence fine on my machine, on Linux. There was a regression in build.rs. glslang being included statically broke compiling the tests. I have no idea how I found that when I wrote down the critical hunk in #44

@knappador
Copy link
Contributor Author

@antiagainst looks like all three platforms have some level of support based on tests? Time to party yet? 📦 🎉

Feel free to keep pinging me on build issues moving forward.

I'm nominating this for merge and not blocked on anything.

@knappador
Copy link
Contributor Author

I'm still thinking about necessary ways to pass through the new options to shaderc-sys. The command line settings "just work." I'm going to add in a patch to pass through the build-from-source feature to shaderc-rs since it's just easier than figuring out a nested dependency configuration for most people.

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

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

This is awesome progress! :) I've a few comments inlined. Thanks for the work again!

shaderc-rs/src/lib.rs Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
shaderc-rs/Cargo.toml Outdated Show resolved Hide resolved
shaderc-sys/build/build.rs Outdated Show resolved Hide resolved
shaderc-sys/src/lib.rs Show resolved Hide resolved
shaderc-sys/build/build.rs Outdated Show resolved Hide resolved
shaderc-sys/build/build.rs Outdated Show resolved Hide resolved
shaderc-sys/build/build.rs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@knappador
Copy link
Contributor Author

I didn't have a lot of time to review changes in f03ba63

Many of the comments were addressed. I'll punch the revision history after changes are more final.

Worth considering how the new structure might affect the docs. I have little experience yet working with Rust docs.
https://docs.rs/shaderc/0.3.16/shaderc/

build-from-source = []
check-inverted-no-defaults = []
inverted-no-defaults = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do you think about shaderc-rs-use-sys-libs and use-sys-libs here then? Given the tight relationship between shaderc-rs and shaderc-sys, it is reasonable to have an option dedicated to shaderc-rs here. (I'm just trying to make the feature more self-documenting. :) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This crazy inversion thing is only necessary because of how --no-default-features operates on a crate's config. I would support a rename to shaderc specific if you keep the backwards compatibility. If you axe the backwards compatibility, these features go away. shaderc-rs-inverted-no-defaults etc would be more appropriate. The features have no control over reading specific directories, only the old behavior of reading the ../out/ directory.

If you decide to axe no defaults, it's as simple as removing these two features in both crates and axing the block in build.rs that reads them, then removing the documents.

The reason I implemented the --no-default-features backwards compatibility is because you believed people were using it (possibly in CI?). It's wise to maintain at least one release of deprecation in any case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SG. This will be removed soon, so I won't bother that much anymore. :)

name = "shaderc_sys"

[features]
check-passthrough = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think another way is just to eliminate the --no-defaults-behavior support for shaderc-rs entirely. It was not a satisfying solution; and now we have SHADERC_LIB_DIR now and it is better. WDYT?

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

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

This is nice, thanks again for doing this! :)

Feel free to do whatever clean up you'd like to and then let me know. I will apply a few cosmetic fixes and then merge this.

…imited and should not be interpreted as a larger coherent change.
…ative to the dependency, not the location of where cargo was invoked. Warn the user if a relative path is relative, not a directory, or fails to resolve (usually file not found becuase of a bad relative path)
@knappador
Copy link
Contributor Author

knappador commented Apr 21, 2019

I added some cleanups after doing some testing and sitting back to leisurely read the code. One feature I actually changed was to try to canonicalize relative paths so that they would work... only to realize that the CWD changes during each recursion cargo makes to a dependency. Specifying a relative path must be done relative to shaderc-sys crate.

--rerun-after-changed and it's env variable counterpart deserve a look. I think we have to combine both for our case, one to detect lib file changes and the other to detect env changes. They have some funky behavior though. I didn't try them.

AFAIK the only outstanding question is to completely axe --no-default-features behavior or leave it deprecated for a few release cycles.

Tests

cargo test
cargo clean
cargo test --features build-from-source
cp ../target/debug/../libshaderc_combined.a ../
cargo clean
cargo test SHADERC_LIB_DIR=../
cargo clean
cargo test --no-default-features
# cp the library into the specified location
# re-run  test --no-default-features
cargo clean
mkdir ../libs
cp /usr/lib/libshaderc_combined.a ../libs/
cp /usr/lib/libglslang.a ../libs/
cp /usr/lib/libSPIRV.a ../libs/
cp /usr/lib/libSPIRV-Tools.a ../libs/
cargo test SHADERC_LIB_DIR=../libs/

knappador and others added 3 commits April 21, 2019 15:01
…nion here since this is a combined crate's README that contains quite a bit of relevant build information for the crate in spite of a lot of shaderc-rs specific information. Two readmes might be a bad idea for maintenance.
@antiagainst
Copy link
Collaborator

Looks good! I just did some final touch over documentation. Will merge soon.

Good point about --no-default-features support. I think with semver, it should be fine to axe it entirely. (Sorry I didn't anticipate it as being this complicated, so I suggested we should support it earlier. We have users of it, see #36) But you already implemented it, let's be nice to keep it for another release. Thanks! :)

@knappador
Copy link
Contributor Author

knappador commented Apr 21, 2019

👍 Changes look good. Thanks for the extensive review, feedback, and refinements

vulkano-rs/vulkano#1183 crosslinking

@antiagainst
Copy link
Collaborator

Merged, thanks! @knappador, it seems I cannot publish shaderc-sys because I don't have the right access. Would you mind add me? Or If you want to do it, please feel free (use the top of the tree). :)

@knappador
Copy link
Contributor Author

knappador commented Apr 22, 2019 via email

@antiagainst
Copy link
Collaborator

https://crates.io/me/pending-invites shows I've no pending owner invites.

@knappador
Copy link
Contributor Author

@antiagainst

Invite sent. If there's no crate, the UI presents no option to manage owners 🙊

cargo publish from within the shaderc-sys crate failed first time. I changed the README path back to relative, success. I can PR this if you're unsure of what I did to get cargo to succeed.

Also it means I burned another semver to give you an invite 🙊 0.4.2 I guess 🐱

@antiagainst
Copy link
Collaborator

Nice, I've access now and published 0.5.0! \o/ Thanks!

Could you yank 0.4.1 now? :)

@knappador knappador deleted the shaderc-sys-split branch April 22, 2019 16:39
@knappador
Copy link
Contributor Author

Yanked. Going to merge this downstream for CI justice.

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.

Use Precompiled Sources to Link Against
3 participants