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

Limit dylib symbols #59752

Merged
merged 3 commits into from
Jun 15, 2019
Merged

Limit dylib symbols #59752

merged 3 commits into from
Jun 15, 2019

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Apr 6, 2019

This makes windows-gnu match the behavior of windows-msvc. It probably doesn't make sense to export these symbols on other platforms either.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 6, 2019
@matthewjasper
Copy link
Contributor

r? @michaelwoerister

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 6, 2019

cc @alexcrichton

@michaelwoerister
Copy link
Member

Note: This should fix issue #53014. Before I approve, I want to discuss the problem some more in that issue in order to make sure we know what exactly is going on.

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 8, 2019

@bors try

@bors
Copy link
Contributor

bors commented Apr 8, 2019

⌛ Trying commit 2f948ea with merge d8873bfe3191043214a8a2630a01ac602be96a01...

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 8, 2019

@michaelwoerister That issue is for msvc, which isn't affected by this PR.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 8, 2019

Note: This should fix issue #53014. Before I approve, I want to discuss the problem some more in that issue in order to make sure we know what exactly is going on.

I'm confused: This code only changes a method in impl<'a> Linker for GccLinker<'a>; but the reports in issue #53014 say that the problem is arising under MSVC. I would have thought that the former would have nothing to do with the latter.

Am I misunderstanding the relationship between the GccLinker type and the MSVC target?

Update: Ah, @Zoxc pointed out the same detail.

@michaelwoerister
Copy link
Member

Ah OK. So this is just a drive-by bug fix?

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 8, 2019

Ran into it when reviving #56987.

@michaelwoerister
Copy link
Member

Well, I guess there's no harm in passing the list of exported symbols to the linker explicitly then. Although there's still the question why it makes a difference (as mentioned in #53014 (comment)).

@michaelwoerister
Copy link
Member

And I wonder if we can also remove the early exit for proc-macros. IIRC, they should only export no_mangle functions.

@bors
Copy link
Contributor

bors commented Apr 8, 2019

☀️ Try build successful - checks-travis
Build commit: d8873bfe3191043214a8a2630a01ac602be96a01

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 8, 2019

@rust-timer build d8873bfe3191043214a8a2630a01ac602be96a01

@rust-timer
Copy link
Collaborator

Success: Queued d8873bfe3191043214a8a2630a01ac602be96a01 with parent 3750348, comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit d8873bfe3191043214a8a2630a01ac602be96a01

@michaelwoerister
Copy link
Member

Looks pretty good! I know @alexcrichton already found in the past that dynamic linking can take up quite a bit of time when compiling small crates.

You can r=me in the current state or try out things with proc-macro early exit also removed.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:03d0faf2:start=1554735105860439897,finish=1554735209490245048,duration=103629805151
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 8, 2019

I wasn't expecting that error, maybe we ignore a proc macro without the right symbols exported?

Anyway, @bors r=michaelwoerister

@bors
Copy link
Contributor

bors commented Apr 8, 2019

📌 Commit 2f948ea has been approved by michaelwoerister

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 8, 2019
Limit dylib symbols

This makes `windows-gnu` match the behavior of `windows-msvc`. It probably doesn't make sense to export these symbols on other platforms either.
@Centril Centril added relnotes Marks issues that should be documented in the release notes of the next release. and removed I-nominated T-release Relevant to the release subteam, which will review and decide on the PR/issue. labels Jun 25, 2019
@Centril
Copy link
Contributor

Centril commented Jun 25, 2019

Discussed at the T-release meeting. @Mark-Simulacrum would be happy to r+ a PR that adds a note to the "known issues" section of the relnotes.

@alexkornitzer
Copy link

alexkornitzer commented Nov 16, 2019

If I understand correctly this PR appears to be the cause of multiple dylib regressions introduced from 1.37.0 forcing people to pin to 1.36.0 if struck by these errors. Furthermore this issue has been present for a rather long time now, if there is no easy solution is it worth fielding the idea of reverting the change? 185dceb The still affected issues appear to be: #64340, #66265 and #65610

@michaelwoerister
Copy link
Member

Thanks for bringing that up, @alexkornitzer.

Nominating for discussing in T-compiler: It looks like we should do something. It's not clear to me, however, if the reported breakage is due to code relying on unspecified implementation details or if this should be considered a bug.

@alexkornitzer
Copy link

Hi @michaelwoerister, did the compiler team manage to reach a consensus on this? I tried looking for the minutes from the last meeting but they don't appear to be online yet.

@michaelwoerister
Copy link
Member

@alexkornitzer This has not been discussed yet, as far as I know.

@alexkornitzer
Copy link

@michaelwoerister that is disappointing but thank you for the update.

@michaelwoerister
Copy link
Member

@Zoxc, did you ever get a chance to take a look at the bug reports above (esp. #64340 and #66265)? It looks to me like the use cases rely on accidental, unspecified behavior with regards to how linking works.

@Zoxc
Copy link
Contributor Author

Zoxc commented Dec 2, 2019

#66265 seems like it should result in a linker error even if exit was exported from Rust since there's multiple definitions of exit. It's not really something that should be supported without explicit support for shadowing symbols (which we don't have).

I haven't look closely at #64340, but it seems to have a problem linking Rust symbols now (not linking to C stuff), which might be a bug with dylibs in rustc.

@solb
Copy link

solb commented Dec 5, 2019

@Zoxc The reason there's no duplicate-definition error in #66265 is that the definitions of the exit symbol are in separate shared object files. It's not a type of shadowing that needs compiler support; rather, this is a concept known as library interposition, which is supported by the dynamic linker itself and is key to how shared libraries work on POSIX systems. (For example, it permits use cases such as runtime heap checking and library call tracing a la ltrace.)

@solb
Copy link

solb commented Dec 5, 2019

@michaelwoerister I've been working with gritty details of shared libraries and the dynamic linker a lot recently, and would be happy to be involved in discussions of this and similar issues when they arise. Any idea when this will come up in triage?

@eddyb
Copy link
Member

eddyb commented Dec 5, 2019

It's not a type of shadowing that needs compiler support;

This is not entirely accurate, as the compiler does need to let the linker see the exports (which is why it doesn't work anymore after this PR was merged, IIUC the discussion here).

I think @Zoxc's point is that we never advertised this as a feature, and so our official position could be that any situation where this worked previously, was merely coincidental and does not constitute "permission" to rely on shadowing.

There could be several reasons to take this stance:

  • supporting shadowing could be at odds with some other goal
    • performance wins of this PR, for example
  • it might not be possible to support it to the same extent on all platforms
  • there may be footgun/safety/soundness concerns around "just letting it happen"

@michaelwoerister
Copy link
Member

@pnkfelix
Copy link
Member

pnkfelix commented Jun 3, 2020

Here is a link to the public archive of the discussion that @michaelwoerister linked above: https://zulip-archive.rust-lang.org/131828tcompiler/28755dyliblinkingbreakage.html

I'm removing the nomination label from this now because I think that discussion essentially covered our thinking at that time, and I don't think much of the thinking has changed since then.

Notably, that discussion did end with:

we should try to write-up an RFC with a plan and decide that way (personally). Making arbitrary changes at this point without having had public discussion feels not great.

(That's all still true, but I don't think anyone has been actually tasked with creating such an RFC or similar public proposal.)

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 26, 2022
… r=nagisa

Fix codegen bug in "ptx-kernel" abi related to arg passing

I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](rust-lang#38788 (comment))), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware.

This PR fixes the bug and add tests for passing structs to ptx kernels.

I observed that all nvptx assembly tests had been marked as [ignore a long time ago](rust-lang#59752 (comment)). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR.

I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated.

Perhaps `@RDambrosio016` would have interest in taking a quick look at this.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 26, 2022
… r=nagisa

Fix codegen bug in "ptx-kernel" abi related to arg passing

I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](rust-lang#38788 (comment))), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware.

This PR fixes the bug and add tests for passing structs to ptx kernels.

I observed that all nvptx assembly tests had been marked as [ignore a long time ago](rust-lang#59752 (comment)). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR.

I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated.

Perhaps ``@RDambrosio016`` would have interest in taking a quick look at this.
@kjetilkjeka kjetilkjeka mentioned this pull request May 8, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet