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

libcore: Add VaList and variadic arg handling intrinsics #49878

Merged
merged 2 commits into from
Nov 29, 2018

Conversation

dlrobertson
Copy link
Contributor

@dlrobertson dlrobertson commented Apr 11, 2018

Summary

  • Add intrinsics for va_start, va_end, va_copy, and va_arg.
  • Add core::va_list::VaList to libcore.

Part 1 of (at least) 3 for #44930

Comments and critiques are very much welcomed 😄

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(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 11, 2018
@TimNN
Copy link
Contributor

TimNN commented Apr 11, 2018

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.
Resolving deltas: 100% (613823/613823), completed with 4888 local objects.
---
[00:00:44] configure: rust.quiet-tests     := True
---
[00:04:36] tidy error: /checkout/src/librustc_trans/type_.rs:330: TODO is deprecated; use FIXME
[00:04:37] some tidy checks failed
[00:04:37]
[00:04:37]
[00:04:37] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:37] expected success, got: exit code: 1
[00:04:37]
[00:04:37]
[00:04:37] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:37] Build completed unsuccessfully in 0:01:45
[00:04:37] Makefile:79: recipe for target 'tidy' failed
[00:04:37] make: *** [tidy] Error 1
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:0e2c5175:start=1523454640590169950,finish=1523454640597313231,duration=7143281
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:095160e0
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:095160e0:start=1523454640603734434,finish=1523454640611305195,duration=7570761
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:08c0cb7c
$ dmesg | grep -i kill
[   10.307371] init: failsafe main process (1093) killed by TERM signal

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)

@petrochenkov
Copy link
Contributor

I'm not familiar with codegen.
r? @eddyb
or ping @nagisa @arielb1 if eddyb is busy

@rust-highfive rust-highfive assigned eddyb and unassigned petrochenkov Apr 12, 2018
Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

The changes look good, but I would probably prefer to see the full implementation before landing, rather than doing it in parts.

AArch64Abi,
PowerPcAbi,
X86_64Abi,
None
Copy link
Member

Choose a reason for hiding this comment

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

Is this variant just a placeholder for targets which haven’t specified their VaList ABI? Removing this variant and picking some default would would end up removing the bug branch from trans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The void or char pointer could be a sensible default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this variant just a placeholder for targets which haven’t specified their VaList ABI?

I don't believe we support one that doesn't specify a VaList ABI, and I can't think of one off the top of my head that hasn't specified their VaList ABI, so unless someone else can think of a reason to keep the none variant, I'll remove it and use void-ptr or char-ptr as the default.

},
_ => {
// TODO: Is this the right thing to do?
bug!("va_list: not supported for this target type");
Copy link
Member

Choose a reason for hiding this comment

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

Yes, bug-ing out here is the right thing to do as the valid variants are filtered out earlier. Message could be made to point out the issue better, though:

unexpected va_list kind reached trans

for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 much better. I'll do a bit more research, but I think defaulting to either a void pointer or char pointer would be reasonable.

@dlrobertson
Copy link
Contributor Author

I would probably prefer to see the full implementation before landing

I'll be in airports all weekend, but I can try to get the commit with VaList implemented in libcore up early next week.

@rust-highfive
Copy link
Collaborator

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.
Resolving deltas: 100% (617013/617013), completed with 4915 local objects.
---
[00:00:44] configure: rust.quiet-tests     := True
---
[00:40:40] warning: [va_arg] cannot be resolved, ignoring it...
---
[00:42:59] .................................................................................i..................
[00:43:05] ........................i...........................................................................
---
[00:43:48] .....................i...........................................................................i..
[00:43:54] ....................................................................................................
[00:44:00] ...........ii.......................................................................................
[00:44:09] ............................................................................................i.......
---
[00:44:45] .............................................i......................................................
---
[00:48:37] ..............................i.....................................................................
[00:48:51] ...............................................................i....................................
[00:49:06] .................................................i..................................................
[00:49:26] ....................................................................................................
[00:49:47] ....................................................................................................
[00:50:07] ....................................................................................................
[00:50:32] .......i............................................................................................
[00:51:01] ...i......................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:51:06] ..........
[00:51:38] ....................................................................................................
[00:52:08] .....................................................................ii.............................
[00:53:00] ................................i....................................................i.ii........test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:53:01] ...
[00:53:41] .............................................................................................iiiiiii
---
[00:55:53] ...................i............................................................ii.iii..............
[00:56:00] ....................................................................................................
[00:56:08] ........i..............................i............................................................
[00:56:15] ....................................................................................................
[00:56:22] ..........i.........................................................................................
[00:56:30] ....................................................................................................
[00:56:39] ....................................................................................................
[00:56:49] ....................................................................................................
[00:57:00] ....................................................................................................
[00:57:12] ....................................................................................................
[00:57:19] ...i................................................................................................
[00:57:28] .......i..ii........................................................................................
[00:57:39] ....................................................................................................
[00:57:48] ....................................................................................................
[00:57:57] .........................................................................i..........................
[00:58:07] ...................i................................................................................
---
[00:58:40] ...........................i........................................................................
[00:58:42] ....................................................................i...............................
[00:58:43] ................i.......................................................
---
[00:58:58] .............i........................
---
[00:59:28] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[00:59:31] i.......i......................i.......
---
[01:00:09] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:00:10] ....ii...
---
[01:07:17] ..................i.................................................................................
[01:08:51] ........i...........................................................................................
---
[01:10:52] .....................................i..............................................................
[01:11:12] ....................................................................................................
[01:11:32] ..........................................i.........................................................
---
[01:13:02] .........................................................ii.........................................
---
[01:14:24] .....................i..............................................................................
---
[01:19:50] ii..................................................................................................
[01:20:10] ....................................................................................................
[01:20:27] .......................iii......i......i...i......i.................................................
[01:20:36] ....................................................................................................
[01:20:51] .............................................iiii........ii.........................................
[01:21:02] ....................................................................................................
[01:21:19] ............................................................................................i.......
[01:21:42] ....................................................................................................
[01:21:54] ....................................................................................................
[01:22:04] ..iiii...............................................
---
[01:28:22] std/intrinsics/fn.va_end.html:59: broken link - std/intrinsics/fn.va_start
[01:28:22] std/intrinsics/fn.va_end.html:60: broken link - std/intrinsics/fn.va_copy
[01:28:22] std/intrinsics/index.html:1916: broken link - std/intrinsics/fn.va_start
[01:28:22] std/intrinsics/index.html:1917: broken link - std/intrinsics/fn.va_copy
[01:28:31] core/intrinsics/fn.va_end.html:59: broken link - core/intrinsics/fn.va_start
[01:28:31] core/intrinsics/fn.va_end.html:60: broken link - core/intrinsics/fn.va_copy
[01:28:31] core/intrinsics/index.html:1909: broken link - core/intrinsics/fn.va_start
[01:28:31] core/intrinsics/index.html:1910: broken link - core/intrinsics/fn.va_copy
[01:28:37] thread 'main' panicked at 'found some broken links', tools/linkchecker/main.rs:49:9
---
[01:28:37] make: *** [check] Error 1
[01:28:37] Makefile:58: recipe for target 'check' failed
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:0203b0b8:start=1523970196743178500,finish=1523970196755294281,duration=12115781
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:18f77766
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:18f77766:start=1523970196766937437,finish=1523970196778607460,duration=11670023
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:09d272ac
$ dmesg | grep -i kill
[   10.991686] init: failsafe main process (1096) killed by TERM signal

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
Copy link
Collaborator

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.
Resolving deltas: 100% (616537/616537), completed with 4918 local objects.
---
[00:00:54] configure: rust.quiet-tests     := True
---
[00:42:09] .................................................................................i..................
[00:42:15] ........................i...........................................................................
---
[00:42:56] .....................i...........................................................................i..
[00:43:02] ....................................................................................................
[00:43:09] ...........ii.......................................................................................
[00:43:17] ............................................................................................i.......
---
[00:43:53] .............................................i......................................................
---
[00:47:38] ..............................i.....................................................................
[00:47:52] ...............................................................i....................................
[00:48:06] .................................................i..................................................
[00:48:25] ....................................................................................................
[00:48:45] ....................................................................................................
[00:49:06] ....................................................................................................
[00:49:29] .......i............................................................................................
[00:49:59] ...i.........................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:50:02] .......
[00:50:33] ....................................................................................................
[00:51:03] .....................................................................ii.............................
[00:51:54] ................................i....................................................i.ii...........
[00:51:55] test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:52:33] .............................................................................................iiiiiii
---
[00:54:43] ...................i............................................................ii.iii..............
[00:54:50] ....................................................................................................
[00:54:58] ........i..............................i............................................................
[00:55:05] ....................................................................................................
[00:55:12] ..........i.........................................................................................
[00:55:20] ....................................................................................................
[00:55:30] ....................................................................................................
[00:55:40] ....................................................................................................
[00:55:50] ....................................................................................................
[00:56:02] ....................................................................................................
[00:56:09] ...i................................................................................................
[00:56:18] .......i..ii........................................................................................
[00:56:28] ....................................................................................................
[00:56:37] ....................................................................................................
[00:56:46] .........................................................................i..........................
[00:56:57] ...................i................................................................................
---
[00:57:30] ...........................i........................................................................
[00:57:31] ....................................................................i...............................
[00:57:32] ................i.......................................................
---
[00:57:48] .............i........................
---
[00:58:17] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[00:58:20] i.......i......................i.......
---
[00:58:58] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[00:58:59] ....ii...
---
[01:05:55] ..................i.................................................................................
[01:07:29] ........i...........................................................................................
---
[01:09:21] .....................................i..............................................................
[01:09:40] ....................................................................................................
[01:09:59] ..........................................i.........................................................
---
[01:11:26] .........................................................ii.........................................
---
[01:12:45] .....................i..............................................................................
---
[01:17:55] ii..................................................................................................
[01:18:15] ....................................................................................................
[01:18:31] .......................iii......i......i...i......i.................................................
[01:18:40] ....................................................................................................
[01:18:55] .............................................iiii........ii.........................................
[01:19:06] ....................................................................................................
[01:19:23] ............................................................................................i.......
[01:19:46] ....................................................................................................
[01:19:57] ....................................................................................................
[01:20:07] ..iiii...............................................
---
[01:26:03] std/intrinsics/fn.va_end.html:59: broken link - std/intrinsics/fn.va_start
[01:26:03] std/intrinsics/fn.va_end.html:60: broken link - std/intrinsics/fn.va_copy
[01:26:03] std/intrinsics/fn.va_start.html:59: broken link - std/intrinsics/fn.va_arg
[01:26:03] std/intrinsics/index.html:1916: broken link - std/intrinsics/fn.va_start
[01:26:03] std/intrinsics/index.html:1917: broken link - std/intrinsics/fn.va_copy
[01:26:03] std/intrinsics/index.html:1925: broken link - std/intrinsics/fn.va_arg
[01:26:11] core/intrinsics/fn.va_end.html:59: broken link - core/intrinsics/fn.va_start
[01:26:11] core/intrinsics/fn.va_end.html:60: broken link - core/intrinsics/fn.va_copy
[01:26:11] core/intrinsics/fn.va_start.html:59: broken link - core/intrinsics/fn.va_arg
[01:26:11] core/intrinsics/index.html:1909: broken link - core/intrinsics/fn.va_start
[01:26:11] core/intrinsics/index.html:1910: broken link - core/intrinsics/fn.va_copy
[01:26:11] core/intrinsics/index.html:1918: broken link - core/intrinsics/fn.va_arg
---
122308 ./obj/build/bootstrap/debug/incremental/bootstrap-351vorei3hhuv/s-f07b1ew9gk-1e3u9p4-1k86flishkqwv
---
101196 ./obj/build/bootstrap/debug/incremental/bootstrap-zki88qpb4pjm/s-f07c488ery-2uy5dz-14mc0iqu0r5mn
91728 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps
90108 ./obj/build/x86_64-unknown-linux-gnu/stage1
90084 ./obj/build/x86_64-unknown-linux-gnu/stage1/lib
89688 ./src/llvm/test/CodeGen
88712 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz
88708 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz/s-f07c1vne0e-m7bhan-3qf3mk1askxcf
---
53212 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/incremental/syntax-33oa6nnkk1g08/s-f07c3hkns3-40g0n9-3dxcw1ob0971a

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
Copy link
Collaborator

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.
Resolving deltas: 100% (616705/616705), completed with 4918 local objects.
---
[00:00:57] configure: rust.quiet-tests     := True
---
[00:46:56] .................................................................................i..................
[00:47:02] ........................i...........................................................................
---
[00:47:46] .....................i...........................................................................i..
[00:47:52] ....................................................................................................
[00:47:59] ...........ii.......................................................................................
[00:48:07] ............................................................................................i.......
---
[00:48:47] .............................................i......................................................
---
[00:52:55] ..............................i.....................................................................
[00:53:09] ...............................................................i....................................
[00:53:25] .................................................i..................................................
[00:53:46] ....................................................................................................
[00:54:08] ....................................................................................................
[00:54:30] ....................................................................................................
[00:54:56] .......i............................................................................................
[00:55:23] ...i.............................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:55:33] ...................
[00:56:06] ....................................................................................................
[00:56:39] .....................................................................ii.............................
[00:57:29] ................................i..............................................test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:57:37] ......i.ii...........
[00:58:21] .............................................................................................iiiiiii
---
[01:00:42] ....................i............................................................ii.iii.............
[01:00:50] ....................................................................................................
[01:00:58] .........i..............................i...........................................................
[01:01:05] ....................................................................................................
[01:01:12] ...........i........................................................................................
[01:01:21] ....................................................................................................
[01:01:30] ....................................................................................................
[01:01:41] ....................................................................................................
[01:01:52] ....................................................................................................
[01:02:06] ....................................................................................................
[01:02:14] ....i...............................................................................................
[01:02:23] ........i..ii.......................................................................................
[01:02:34] ....................................................................................................
[01:02:43] ....................................................................................................
[01:02:53] ..........................................................................i.........................
[01:03:03] ....................i...............................................................................
---
[01:03:38] ...........................i........................................................................
[01:03:39] ....................................................................i...............................
[01:03:40] ...............i.......................................................
---
[01:03:57] .............i........................
---
[01:04:28] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[01:04:31] i.......i......................i.......
---
[01:05:10] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:05:12] ....ii...
---
[01:13:29] ..................i.................................................................................
[01:15:14] ........i...........................................................................................
---
[01:17:21] .....................................i..............................................................
[01:17:43] ....................................................................................................
[01:18:06] ..........................................i.........................................................
---
[01:19:39] .........................................................ii.........................................
---
[01:21:06] .....................i..............................................................................
---
[01:26:42] ii..................................................................................................
[01:27:03] ....................................................................................................
[01:27:20] .......................iii......i......i...i......i.................................................
[01:27:30] ....................................................................................................
[01:27:46] .............................................iiii........ii.........................................
[01:27:58] ....................................................................................................
[01:28:15] ............................................................................................i.......
[01:28:41] ....................................................................................................
[01:28:53] ....................................................................................................
[01:29:04] ..iiii...............................................
---
[01:35:16] std/intrinsics/fn.va_end.html:2: broken link - std/intrinsics/fn.va_start
[01:35:16] std/intrinsics/fn.va_end.html:3: broken link - std/intrinsics/fn.va_copy
[01:35:16] std/intrinsics/fn.va_start.html:2: broken link - std/intrinsics/fn.va_arg
[01:35:16] std/intrinsics/index.html:1859: broken link - std/intrinsics/fn.va_start
[01:35:16] std/intrinsics/index.html:1860: broken link - std/intrinsics/fn.va_copy
[01:35:16] std/intrinsics/index.html:1868: broken link - std/intrinsics/fn.va_arg
[01:35:25] core/intrinsics/fn.va_end.html:2: broken link - core/intrinsics/fn.va_start
[01:35:25] core/intrinsics/fn.va_end.html:3: broken link - core/intrinsics/fn.va_copy
[01:35:25] core/intrinsics/fn.va_start.html:2: broken link - core/intrinsics/fn.va_arg
[01:35:25] core/intrinsics/index.html:1852: broken link - core/intrinsics/fn.va_start
[01:35:25] core/intrinsics/index.html:1853: broken link - core/intrinsics/fn.va_copy
[01:35:25] core/intrinsics/index.html:1861: broken link - core/intrinsics/fn.va_arg
[01:35:31] thread 'main' panicked at 'found some broken links', tools/linkchecker/main.rs:49:9
---
[01:35:31] make: *** [check] Error 1
[01:35:31] Makefile:58: recipe for target 'check' failed
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:16f54d06:start=1523998992908371833,finish=1523998992923970785,duration=15598952
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:0600ccca
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:0600ccca:start=1523998992930712028,finish=1523998992937289954,duration=6577926
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:020702ae
$ dmesg | grep -i kill
[   10.678826] init: failsafe main process (1096) killed by TERM signal

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)

@bors
Copy link
Contributor

bors commented Apr 21, 2018

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

@rust-highfive
Copy link
Collaborator

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:56:04] ....i......................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:56:09] .........
[00:56:41] ....................................................................................................
[00:57:10] ......................................................................ii............................
[00:58:02] .................................i....................................................i.ii.....test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:58:47] ..............................................................................................iiiiii
[00:59:14] i...................................................................................................
[00:59:44] ....................................................................................................
[01:00:10] ....................................................................................................
---
[01:33:32] travis_fold:end:stage0-linkchecker

[01:33:32] travis_time:end:stage0-linkchecker:start=1524363993598161550,finish=1524363996559484103,duration=2961322553

[01:33:35] std/intrinsics/fn.va_end.html:2: broken link fragment `#fn.va_start` pointing to `std/intrinsics/fn.va_end.html`
[01:33:35] std/intrinsics/fn.va_end.html:3: broken link fragment `#fn.va_copy` pointing to `std/intrinsics/fn.va_end.html`
[01:33:35] std/intrinsics/fn.va_start.html:2: broken link fragment `#fn.va_arg` pointing to `std/intrinsics/fn.va_start.html`
[01:33:35] std/intrinsics/index.html:1859: broken link fragment `#fn.va_start` pointing to `std/intrinsics/index.html`
[01:33:35] std/intrinsics/index.html:1860: broken link fragment `#fn.va_copy` pointing to `std/intrinsics/index.html`
[01:33:35] std/intrinsics/index.html:1868: broken link fragment `#fn.va_arg` pointing to `std/intrinsics/index.html`
[01:33:43] core/intrinsics/fn.va_end.html:2: broken link fragment `#fn.va_start` pointing to `core/intrinsics/fn.va_end.html`
[01:33:43] core/intrinsics/fn.va_end.html:3: broken link fragment `#fn.va_copy` pointing to `core/intrinsics/fn.va_end.html`
[01:33:43] core/intrinsics/fn.va_start.html:2: broken link fragment `#fn.va_arg` pointing to `core/intrinsics/fn.va_start.html`
[01:33:43] core/intrinsics/index.html:1852: broken link fragment `#fn.va_start` pointing to `core/intrinsics/index.html`
[01:33:43] core/intrinsics/index.html:1853: broken link fragment `#fn.va_copy` pointing to `core/intrinsics/index.html`
[01:33:43] core/intrinsics/index.html:1861: broken link fragment `#fn.va_arg` pointing to `core/intrinsics/index.html`

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:039409e6
$ 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)

@bors
Copy link
Contributor

bors commented Apr 26, 2018

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

@pietroalbini
Copy link
Member

Ping from triage @eddyb! This PR needs your review.
Also @dlrobertson, there are a bunch of conflicts that needs to be fixed.

@dlrobertson
Copy link
Contributor Author

@pietroalbini I can push up a rebased branch shortly.

@nagisa @eddyb I'm still working on the actual VaList implementation in libcore. I have a WIP commit that includes it that doesn't currently generate the correct code yet. Would you prefer me to push that code to this branch as well?

@nagisa
Copy link
Member

nagisa commented Apr 30, 2018

Feel free to push whenever you have any changes. It is easier to stay up-to-date with the state of the PR that way and it might avoid the pings from triage.

VoidPtr,
AArch64Abi,
PowerPcAbi,
X86_64Abi,
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why this enum was added, instead of determining this information from the architecture, in the call ABI (formerly src/librustc_trans/{abi,cabi_*}.rs, now in src/librustc_target/abi/call/*.rs) infrastructure.

Copy link
Member

Choose a reason for hiding this comment

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

Is there value in custom target specifications overriding it? Currently we don't support overriding most of the behavior of the C call ABI for a 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.

My main motivation for using this approach was because it more closely mirrored clang's implementation. Other than that, it makes windows a bit easier. Windows may be x86_64, but the va_list implementation is the CharPtr variant. That being said, I think we could use is_windows_like and the architecture.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we already special-case windows in call ABI code. Also, I'm curious what it affects, in terms of the final implementation - is it just required to be something that only LLVM operates on, or would rustc_trans also have to generate code looking at its fields etc.?

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'm honestly not entirely sure yet. I'm still a rustc noobie, and I'm still reading through much of the trans code. I was hoping that rustc_trans::Type::va_list could be the only function that needed this enum, but the VaList argument would get eliminated as an argument due to the core implementation being a ZST.

I was also hoping that we could generate better debug info for architectures like x86_64 and Aarch64, but I haven't gotten that far yet.

@eddyb
Copy link
Member

eddyb commented Apr 30, 2018

Sorry about the delay, I wish I had read through this sooner - had I said anything about #49878 (comment) sooner, conflicts with #50228 would've been avoided.
Aside from that, the patch looks good, and I'm excited to see the VaList implementation!

@dlrobertson
Copy link
Contributor Author

Sorry about the delay

Np. Nothing a little vimdiff can't fix

Copy link
Contributor Author

@dlrobertson dlrobertson left a comment

Choose a reason for hiding this comment

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

@eddyb @nagisa Added the WIP commit adding VaList to core.

reason = "dlrobertson is still working on this",
issue = "27745")]
#[derive(Debug)]
pub struct VaList;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original RFC indicates that this should be implemented as core::intrinsics::VaList, but since everything in intrinsics is a "rust-intrinsic" I implemented it as core::va_list::VaList. Was there a reason this was going to be implemented under intrinsics?

@@ -2694,6 +2695,34 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.object_lifetime_defaults_map(id.owner)
.and_then(|map| map.get(&id.local_id).cloned())
}

pub fn va_list_types(&self) -> Vec<Ty<'tcx>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used to get the Tys of the VaList fields. I'm still working on figuring out what to do here for the pointer variants. I'm not sure if the current implementation works for them. My first attempt only used Type::va_list, but the VaList function argument would get optimized out as a ZST, so I added extra logic here so that the LayoutDetails indicate that the VaList is not a ZST. Comments and critiques on this would be super helpful.

let variants = tcx.va_list_types().iter()
.map(|x| self.layout_of(x).unwrap())
.collect::<Vec<_>>();
univariant_uninterned(&variants[..], &def.repr, kind)?
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 don't think this is entirely correct. I think this will not be correct for the CharPtr and VoidPtr variants.

@@ -1614,6 +1624,13 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
this.ty.simd_type(tcx)
}

ty::TyAdt(def, ..) if Some(def.did) == tcx.lang_items().va_list() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The VaList implementation in core is just a stub. When compiling for X86_64, any access to field will result in an out of bounds index.

@@ -297,4 +298,34 @@ impl Type {
pub fn x86_mmx(cx: &CodegenCx) -> Type {
ty!(llvm::LLVMX86MMXTypeInContext(cx.llcx))
}

pub fn va_list(cx: &CodegenCx, name: &str) -> Type {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function used to generate the correct type.

@eddyb
Copy link
Member

eddyb commented Apr 30, 2018

@dlrobertson Looking again at the RFC, it seems to me that the logic for picking the fields of VaList should be done with #[cfg]'s in libcore, instead of magically within the compiler.
At least we can do that today and we know it would work, whereas doing it in the compiler would be harder. Ideally VaList would be an extern type always behind a &mut, but can it be?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.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:2b685ce8:start=1543270798200971514,finish=1543270800681784872,duration=2480813358
$ 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
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---

[00:03:21] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:21] tidy error: /checkout/src/librustc_codegen_llvm/intrinsic.rs:153: line longer than 100 chars
[00:03:21] tidy error: /checkout/src/librustc_codegen_llvm/intrinsic.rs:162: line longer than 100 chars
[00:03:23] some tidy checks failed
[00:03:23] 
[00:03:23] 
[00:03:23] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:23] 
[00:03:23] 
[00:03:23] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:23] Build completed unsuccessfully in 0:00:58
[00:03:23] Build completed unsuccessfully in 0:00:58
[00:03:23] Makefile:79: recipe for target 'tidy' failed
[00:03:23] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:02b506d2
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Nov 26 22:23:32 UTC 2018
---
travis_time:end:0003e54a:start=1543271013201234980,finish=1543271013206629907,duration=5394927
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0f7088b4
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1038891c
travis_time:start:1038891c
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0996240c
$ 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)

 - Add the llvm intrinsics used to manipulate a va_list.
 - Add the va_list lang item in order to allow implementing
   VaList in libcore.
@dlrobertson
Copy link
Contributor Author

I've tested on x86_64-pc-windows-gnu and x86_64-unknown-linux-gnu. Any other targets you'd like me to test before it is handed over to bors?

@eddyb
Copy link
Member

eddyb commented Nov 27, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Nov 27, 2018

📌 Commit e9e084f has been approved by eddyb

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 27, 2018
@bors
Copy link
Contributor

bors commented Nov 29, 2018

⌛ Testing commit e9e084f with merge 3e90a12...

bors added a commit that referenced this pull request Nov 29, 2018
libcore: Add VaList and variadic arg handling intrinsics

## Summary

 - Add intrinsics for `va_start`, `va_end`, `va_copy`, and `va_arg`.
 - Add `core::va_list::VaList` to `libcore`.

Part 1 of (at least) 3 for #44930

Comments and critiques are very much welcomed 😄
@bors
Copy link
Contributor

bors commented Nov 29, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 3e90a12 to master...

@bors bors merged commit e9e084f into rust-lang:master Nov 29, 2018
@dlrobertson
Copy link
Contributor Author

\o/ Thanks @eddyb @joshtriplett @rkruppe and everyone else who helped me work through this!

@RalfJung
Copy link
Member

Is it possible that this creates unaligned slices, thus causing #55011 (comment) ?

@dlrobertson
Copy link
Contributor Author

Is it possible that this creates unaligned slices, thus causing #55011 (comment) ?

After a very brief review, it looks like an issue with the test.

@glguy
Copy link

glguy commented Dec 4, 2018

This PR merges the platform specific aspects of va_copy with a particular access pattern via higher-order function that enforces a particular use pattern of va_end afterward.

I ran into an example of a non-standard use-case here: https://github.com/GNOME/libxml2/blob/35e83488505d501864826125cfe6a7950d6cba78/xmlwriter.c#L4483-L4497

My proposal would be to move the architecture-specific logic out into its own method that was used to implement the copy method. https://github.com/rust-lang/rust/blob/master/src/libcore/ffi.rs#L193-L202

I'd be curious to hear your opinions!

@dlrobertson
Copy link
Contributor Author

@glguy I don't see how you could implement a similar function with the current interface. This is indeed a non-standard use case, so I don't see it having an impact on the methods implemented for VaList. If we did want to support such a use case I think our best option is to implement Default for VaList and expose the raw intrinsics. You might create an issue about this or comment on the RFC rust-lang/rfcs#2137.

@eddyb
Copy link
Member

eddyb commented Dec 6, 2018

@glguy That code is only awkward because it (mis-)uses a while loop.
In Rust, you'd just use loop. This is how you can re-write the C loop:

    while(1) {
        VA_COPY(locarg, argptr);
        count = vsnprintf((char *) buf, size, format, locarg);
        va_end(locarg);
        if (!((count < 0) || (count == size - 1) || (count == size) || (count > size))) {
            break;
        }
        xmlFree(buf);
        size += BUFSIZ;
        buf = (xmlChar *) xmlMalloc(size);
        if (buf == NULL) {
            xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
                            "xmlTextWriterVSprintf : out of memory!\n");
            return NULL;
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-c_variadic `#![feature(c_variadic)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.