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

Prohibit `global_allocator` in submodules #51335

Merged
merged 6 commits into from Jun 25, 2018

Conversation

Projects
None yet
9 participants
@mark-i-m
Copy link
Contributor

commented Jun 4, 2018

Background: #44113 is caused by weird interactions with hygiene. Hygiene is hard. After a lot of playing around, we decided that the best path forward would be to prohibit global_allocators from being in submodules for now. When somebody gets it working, we can re-enable it.

This PR contains the following

  • Some hygiene "fixes" -- things I suspect are the correct thing to do that will make life easier in the future. This includes using call_site hygiene for the generated module and passing the correct crate name to the expansion config.
  • Comments and minor formatting fixes
  • Some debugging code
  • Code to prohibit global_allocator in submodules
  • Test checking that the proper error occurs.

cc #44113 #49320 #51241

r? @alexcrichton

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 4, 2018

The job x86_64-gnu-llvm-3.9 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.
[00:43:10] ............................................................................i.......................
[00:43:14] ....................................................................................................
[00:43:20] ....................................................................................................
[00:43:26] ....................................................................................................
[00:43:30] .........i.................iiiiiiiii...................................................
[00:43:30] 
[00:43:30] travis_fold:start:test_ui_nll
travis_time:start:test_ui_nll
Check compiletest suite=ui mode=ui compare_mode=nll (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
[00:44:20] ............................................................................i.......................
[00:44:25] ....................................................................................................
[00:44:29] ....................................................................................................
[00:44:35] ....................................................................................................
[00:44:39] .........i..................iiiiiiiii..................................................
[00:44:39] 
[00:44:39]  finished in 68.810
[00:44:39] travis_fold:end:test_ui_nll

---
[00:47:28] ....................................................................................................
[00:47:39] ....................................................................................................
[00:47:50] ....................................................................................................
[00:48:12] ...........................................................i........................................
[00:48:24] ..........................................................................................F..i......
[00:48:52] ..............................................................................test [run-pass] run-pass/issue-29227.rs has been running for over 60 seconds
[00:48:58] ......................
[00:49:23] ....................................................................................................
[00:49:35] ....................................................................................................
---
[00:52:15] ................................................iiiiiii.............................................
[00:52:34] ....................................................................................................
[00:52:49] ....................................................................................................
[00:53:09] ....................................................................................................
" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:53:30] 
[00:53:30] 
[00:53:30] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:53:30] Build completed unsuccessfully in 0:12:32
[00:53:30] Build completed unsuccessfully in 0:12:32
[00:53:30] Makefile:58: recipe for target 'check' failed
[00:53:30] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:06e4cb7a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 6, 2018

The job x86_64-gnu-llvm-3.9 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.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/5f/86/363f1249d0b62d7cce3cb8973fb6715b57ca75f8425d6c45fe5e129531a9/awscli-1.15.33-py2.py3-none-any.whl (1.3MB)
    0% |▎                               | 10kB 3.7MB/s eta 0:00:01
    1% |▌                               | 20kB 1.6MB/s eta 0:00:01
    2% |▉                               | 30kB 1.8MB/s eta 0:00:01
    3% |█                               | 40kB 1.8MB/s eta 0:00:01
---
[00:13:17]    Compiling rustc_mir v0.0.0 (file:///checkout/src/librustc_mir)
[00:13:17]    Compiling rustc_typeck v0.0.0 (file:///checkout/src/librustc_typeck)
[00:16:10]    Compiling rustc_resolve v0.0.0 (file:///checkout/src/librustc_resolve)
[00:16:11]    Compiling rustc_allocator v0.0.0 (file:///checkout/src/librustc_allocator)
[00:16:12] error[E0412]: cannot find type `Mac` in this scope
[00:16:12]    --> librustc_allocator/expand.rs:171:33
[00:16:12]     |
[00:16:12] 171 |     fn fold_mac(&mut self, mac: Mac) -> Mac {
[00:16:12]     |                                 ^^^ not found in this scope
[00:16:12] help: possible candidate is found in another module, you can import it into scope
[00:16:12] 11  | use syntax::ast::Mac;
[00:16:12]     |
[00:16:12] 
[00:16:12] 
[00:16:12] error[E0412]: cannot find type `Mac` in this scope
[00:16:12]    --> librustc_allocator/expand.rs:171:41
[00:16:12]     |
[00:16:12] 171 |     fn fold_mac(&mut self, mac: Mac) -> Mac {
[00:16:12]     |                                         ^^^ not found in this scope
[00:16:12] help: possible candidate is found in another module, you can import it into scope
[00:16:12] 11  | use syntax::ast::Mac;
[00:16:12]     |
[00:16:12] 
[00:16:12] error: aborting due to 2 previous errors
[00:16:12] error: aborting due to 2 previous errors
[00:16:12] 
[00:16:12] For more information about this error, try `rustc --explain E0412`.
[00:16:12] error: Could not compile `rustc_allocator`.
[00:16:12] 
[00:16:12] Caused by:
[00:16:12]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_allocator librustc_allocator/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=74cdf675d98e099e -C extra-filename=-74cdf675d98e099e --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-4c5434c80172b18c.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-5073f1296cd24b67.rlib --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-0404335fb4ae3dc1.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-58741ed9de9aae4f.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-41b116eaee1e5535.so --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-a30c37d59a6fc275.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-88673787176f9d86/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-62d80197b9ec531e/out` (exit code: 101)
[00:17:34] error: build failed
[00:17:34] error: build failed
[00:17:34] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:17:34] expected success, got: exit code: 101
[00:17:34] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1091:9
[00:17:34] travis_fold:end:stage0-rustc

[00:17:34] travis_time:end:stage0-rustc:start=1528245101186962730,finish=1528245857939140127,duration=756752177397


[00:17:34] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:17:34] Build completed unsuccessfully in 0:12:48
[00:17:34] make: *** [all] Error 1
[00:17:34] Makefile:28: recipe for target 'all' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:3585ef20
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@mark-i-m mark-i-m force-pushed the mark-i-m:allocator branch from 08be7e8 to 461d3e0 Jun 6, 2018

@pietroalbini

This comment has been minimized.

Copy link
Member

commented Jun 18, 2018

The reviewer is currently away. Maybe someone else from @rust-lang/compiler can review this?

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2018

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2018

📌 Commit 461d3e0 has been approved by oli-obk

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2018

🔒 Merge conflict

@pietroalbini

This comment has been minimized.

Copy link
Member

commented Jun 18, 2018

@mark-i-m you need to rebase on top of the latest master.

@mark-i-m mark-i-m force-pushed the mark-i-m:allocator branch from 461d3e0 to 558be1e Jun 19, 2018

@mark-i-m

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2018

Rebased

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 19, 2018

The job x86_64-gnu-llvm-3.9 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:start:test_ui
Check compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:42:42] 
[00:42:42] running 1504 tests
[00:42:46] ........F....................................................................................i......
[00:42:56] ....................................................................................................
[00:42:59] ....................................................................................................
[00:43:03] ....................................................................................................
[00:43:06] ....................................................................................................
---
[00:43:36] ....................................................................................................
[00:43:42] ....................................................................................................
[00:43:47] ....................................................................................................
[00:43:53] ...................i................................................................................
inux-gnu/test/ui/allocator-submodule/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/allocator-submodule/auxiliary" "-A" "unused"
[00:43:54] ------------------------------------------
[00:43:54] 
[00:43:54] ------------------------------------------
[00:43:54] stderr:
[00:43:54] stderr:
[00:43:54] ------------------------------------------
[00:43:54] {"message":"`global_allocator` cannot be used in submodules","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/allocator-submodule.rs","byte_start":989,"byte_end":1023,"line_start":34,"line_end":34,"column_start":5,"column_end":39,"is_primary":true,"text":[{"text":"    static MY_HEAP: MyAlloc = MyAlloc; //~ ERROR global_allocator","highlight_start":5,"highlight_end":39}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: `global_allocator` cannot be used in submodules\n  --> /checkout/src/test/ui/allocator-submodule.rs:34:5\n   |\nLL |     static MY_HEAP: MyAlloc = MyAlloc; //~ ERROR global_allocator\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:43:54] {"message":"unresolved import `std::alloc::Opaque`","code":{"code":"E0432","explanation":"\nAn import was unresolved.\n\nErroneous code example:\n\n```compile_fail,E0432\nuse something::Foo; // error: unresolved import `something::Foo`.\n```\n\nPaths in `use` statements are relative to the crate root. To import items\nrelative to the current and parent modules, use the `self::` and `super::e            768M     0  768M   0% /var/ramfs
31740 ./.git/modules/src/libcompiler_builtins/modules/compiler-rt/objects/pack
31668 ./obj/build/x86_64-unknown-linux-gnu/doc/src
31532 ./src/libcompiler_builtins/compiler-rt/test
27892 ./.git/modules/src/tools/lld
---
travis_time:end:201449f4:start=1529370078953385609,finish=1529370078960082113,duration=6696504
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:199f0db2
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:05c06df6
$ dmesg | grep -i kill

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)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jun 19, 2018

The job x86_64-gnu-llvm-3.9 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:start:test_ui
Check compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:42:59] 
[00:42:59] running 1504 tests
[00:43:03] ........F....................................................................................i......
[00:43:13] ....................................................................................................
[00:43:16] ....................................................................................................
[00:43:20] ....................................................................................................
[00:43:23] ....................................................................................................
---
[00:44:12] ...................i................................................................................
re.3
travis_fold:start:after_failure.4
travis_time:start:35547f60
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:269c87b5
$ dmesg | grep -i kill

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)

self.in_submod += 1;
let ret = fold::noop_fold_mod(m, self);
self.in_submod -= 1;
info!("exit submodule");

This comment has been minimized.

Copy link
@eddyb

eddyb Jun 22, 2018

Member

I don't think info!-level debug logging should be kept in. You can use debug!, if you want.

@mark-i-m

This comment has been minimized.

Copy link
Contributor Author

commented Jun 23, 2018

r? @oli-obk Time for another review?

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2018

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2018

📌 Commit d264e25 has been approved by oli-obk

@mark-i-m

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2018

??? I just rebased this?

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2018

☔️ The latest upstream changes (presumably #51726) made this pull request unmergeable. Please resolve the merge conflicts.

mark-i-m added some commits Apr 13, 2018

Prohibit global_allocator in submodules for now
- we need to figure out hygiene first
- change the test to check that the prohibition works with a good error
  msg
- leaves some comments and debugging code
- leaves some of our supposed fixes

@mark-i-m mark-i-m force-pushed the mark-i-m:allocator branch from e869c42 to 16d7f87 Jun 24, 2018

@mark-i-m

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2018

Rebased again

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2018

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2018

📌 Commit 16d7f87 has been approved by oli-obk

@pietroalbini

This comment has been minimized.

Copy link
Member

commented Jun 25, 2018

Let's avoid rebasing this again.

@bors p=1

@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2018

⌛️ Testing commit 16d7f87 with merge 446aef6...

bors added a commit that referenced this pull request Jun 25, 2018

Auto merge of #51335 - mark-i-m:allocator, r=oli-obk
Prohibit `global_allocator` in submodules

Background: #44113 is caused by weird interactions with hygiene. Hygiene is hard. After a lot of playing around, we decided that the best path forward would be to prohibit `global_allocator`s from being in submodules for now. When somebody gets it working, we can re-enable it.

This PR contains the following
- Some hygiene "fixes" -- things I suspect are the correct thing to do that will make life easier in the future. This includes using call_site hygiene for the generated module and passing the correct crate name to the expansion config.
- Comments and minor formatting fixes
- Some debugging code
- Code to prohibit `global_allocator` in submodules
- Test checking that the proper error occurs.

cc #44113 #49320 #51241

r? @alexcrichton
@bors

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 446aef6 to master...

@bors bors merged commit 16d7f87 into rust-lang:master Jun 25, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@pietroalbini

This comment has been minimized.

Copy link
Member

commented Jun 27, 2018

Reason for the beta nomination: global allocators will be stabilized in 1.28, and it's best to prohibit something before it reaches stable.

@mark-i-m

This comment has been minimized.

Copy link
Contributor Author

commented Jun 28, 2018

@pietroalbini is there something I need to do on my end?

@pietroalbini

This comment has been minimized.

Copy link
Member

commented Jun 28, 2018

@mark-i-m no, the compiler team has a meeting later today when they'll decide if this can be backported.

bors added a commit that referenced this pull request Jun 28, 2018

Auto merge of #51857 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports

Merged and approved:

* #51725: Do not build LLVM tools for any of the tools
* #51852: Don't use `ParamEnv::reveal_all()` if there is a real one available
* #51686: yet another "old borrowck" bug around match default bindings
* #51868: Remove process::id from 'Stabilized APIs' in 1.27.0 release notes
*  #51335: Prohibit `global_allocator` in submodules

r? @ghost

@mark-i-m mark-i-m deleted the mark-i-m:allocator branch Nov 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.