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

fix zstd on windows #16293

Closed
wants to merge 2 commits into from
Closed

fix zstd on windows #16293

wants to merge 2 commits into from

Conversation

cha5on
Copy link
Contributor

@cha5on cha5on commented Sep 17, 2022

Sandboxing on Windows is more limited than on other platforms, so two jni_md.h headers were ending up in the include path. This resulted in the wrong jni_md.h header being used on Windows, which meant that the JNIEXPORT macro was not being set to actually export symbols appropriately on Windows. This caused any attempts to use zstd on windows, whether for http_archive, gRPC cache compression, etc. to result in an UnsatisfiedLinkError being thrown.

Change to use a similar method as the main bazel jni stuff, which is to copy the jni.h and jni_md.h headers over. This prevents accidentally picking up a header from the wrong architecture.

Relates to #16041

@sgowroji sgowroji added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website awaiting-review PR is awaiting review from an assigned reviewer labels Sep 19, 2022
genrule(
name = "copy_link_jni_md_header",
srcs = select({
"@io_bazel//src/conditions:darwin": ["@bazel_tools//tools/jdk:jni_md_header-darwin"],
Copy link
Member

Choose a reason for hiding this comment

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

@bazel_tools//src/conditions:* is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated throughout

@meteorcloudy
Copy link
Member

We should try to enable the tests on Windows as well: https://cs.opensource.google/bazel/bazel/+/master:.bazelci/presubmit.yml;l=244-245

"src/windows/include/jni_md.h",
"jni/jni.h",
]) + [
"jni_md.h",
Copy link
Member

Choose a reason for hiding this comment

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

prepend :? e.g. :jni_md.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Sandboxing on Windows is more limited than on other platforms, so two
jni_md.h headers were ending up in the include path.  This resulted in
the wrong jni_md.h header being used on Windows, which meant that the
JNIEXPORT macro was not being set to actually export symbols
appropriately on Windows.  This caused any attempts to use zstd on
windows, whether for http_archive, gRPC cache compression, etc. to
result in an UnsatisfiedLinkError being thrown.

Change to use a similar method as the main bazel jni stuff, which is to
copy the jni.h and jni_md.h headers over.  This prevents accidentally
picking up a header from the wrong architecture.

Relates to bazelbuild#16041
@meteorcloudy
Copy link
Member

Can you also update https://cs.opensource.google/bazel/bazel/+/master:.bazelci/postsubmit.yml;l=252 to the same as the presubmit.yml file?

Copy link
Member

@coeuvre coeuvre left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@cha5on
Copy link
Contributor Author

cha5on commented Sep 20, 2022

Can you also update https://cs.opensource.google/bazel/bazel/+/master:.bazelci/postsubmit.yml;l=252 to the same as the presubmit.yml file?

done!

Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

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

Thank you so much for the fix!

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Sep 21, 2022
copybara-service bot pushed a commit that referenced this pull request Sep 21, 2022
Relates to #16041

Partial commit for third_party/*, see #16293.

Signed-off-by: Sunil Gowroji <sgowroji@google.com>
@sgowroji sgowroji removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Sep 21, 2022
aiuto pushed a commit to aiuto/bazel that referenced this pull request Oct 12, 2022
Relates to bazelbuild#16041

Partial commit for third_party/*, see bazelbuild#16293.

Signed-off-by: Sunil Gowroji <sgowroji@google.com>
aiuto pushed a commit to aiuto/bazel that referenced this pull request Oct 12, 2022
Sandboxing on Windows is more limited than on other platforms, so two jni_md.h headers were ending up in the include path.  This resulted in the wrong jni_md.h header being used on Windows, which meant that the JNIEXPORT macro was not being set to actually export symbols appropriately on Windows.  This caused any attempts to use zstd on windows, whether for http_archive, gRPC cache compression, etc. to result in an UnsatisfiedLinkError being thrown.

Change to use a similar method as the main bazel jni stuff, which is to copy the jni.h and jni_md.h headers over.  This prevents accidentally picking up a header from the wrong architecture.

Relates to bazelbuild#16041

Closes bazelbuild#16293.

PiperOrigin-RevId: 475839895
Change-Id: Ia5569c50c8764699abe9858207a256b921980b92
aiuto pushed a commit to aiuto/bazel that referenced this pull request Oct 12, 2022
Relates to bazelbuild#16041

Partial commit for third_party/*, see bazelbuild#16293.

Signed-off-by: Sunil Gowroji <sgowroji@google.com>
aiuto pushed a commit to aiuto/bazel that referenced this pull request Nov 14, 2022
Relates to bazelbuild#16041

Partial commit for third_party/*, see bazelbuild#16293.

Signed-off-by: Sunil Gowroji <sgowroji@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants