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

Disable ARM EHABI when building without landing pads #11992

Closed
wants to merge 1 commit into from

Conversation

bharrisau
Copy link
Contributor

I'm not sure if/how to test this. Passes make check.

Before

  .globl  _ZN4char8from_u3219h816af907f1240ba2a94v0.0E
  .align  2
  .type _ZN4char8from_u3219h816af907f1240ba2a94v0.0E,%function
_ZN4char8from_u3219h816af907f1240ba2a94v0.0E:
  .fnstart
.Leh_func_begin0:
  push  {r4, r5}
  mov r5, sp
...
.LBB0_5:                                                                                                                                                                                                            
  pop {r4, r5}                                                                                                                                                                                                      
  .save {r11, lr}                                                                                                                                                                                                   
  push  {r11, lr}                                                                                                                                                                                                   
  .setfp  r11, sp                                                                                                                                                                                                   
  mov r11, sp                                                                                                                                                                                                       
  .pad  #24                                                                                                                                                                                                         
  sub sp, sp, #24                                                                                                                                                                                                   
  ldr r2, .LCPI0_3                                                                                                                                                                                                  
.LPC0_0:
...
Ltmp0:
  .size _ZN4char8from_u3219h816af907f1240ba2a94v0.0E, .Ltmp0--ZN4char8from_u3219h816af907f1240ba2a94v0.0E
.Leh_func_end0:
  .fnend

After

  .globl  _ZN4char8from_u3219h816af907f1240ba2a94v0.0E
  .align  2
  .type _ZN4char8from_u3219h816af907f1240ba2a94v0.0E,%function
_ZN4char8from_u3219h816af907f1240ba2a94v0.0E:
  push  {r4, r5}
  mov r5, sp
...
.LBB0_5:
  pop {r4, r5}
  push  {r11, lr}
  mov r11, sp
  sub sp, sp, #24
  ldr r2, .LCPI0_3
.LPC0_0:
...
.Ltmp0:
  .size _ZN4char8from_u3219h816af907f1240ba2a94v0.0E, .Ltmp0-_ZN4char8from_u3219h816af907f1240ba2a94v0.0E

@bharrisau
Copy link
Contributor Author

Saw this mentioned in #10942

@alexcrichton
Copy link
Member

I think it generally makes sense that the behavior is undefined if you run with -Z no-landing-pads. Feel free to xfail-android the test.

@alexcrichton
Copy link
Member

Ah, what I meant to say is that behavior is undefined if you unwind in code built with -Z no-landing-pads

@bharrisau
Copy link
Contributor Author

Yeah, but I didn't think it should be even trying to unwind. I'll admit to not being sure of the intent behind the no-landing-pads switch. Is saying that exceptions with no-landing-pads gives undefined behaviour all right? It looks like the X86 code just doesn't call destructors (I'm not sure if that is better or worse than trying to execute arbitrary code).

@alexcrichton
Copy link
Member

We call a "landing pad" a segment of code which is run whenever an unwinding happens. This means that after some function was called, something down in the call stack ended up calling fail!() triggering an unwinding of the stack. Each call instruction in a function may trigger unwinding, and is then associated with a landing pad. These landing pads are what run destructors when the stack unwinds.

With the -Z no-landing-pads switch, none of these landing pads are generated. They end up calling special functions in the libunwind library which may not be present on all platforms.

On ARM, it looks like the codegen is so different that if the code isn't built to have exceptions thrown that there's no way for libunwind to unwind the stack when an exception is thrown. I suppose it doesn't affect x86 and x86_64 codegen that much.

I was basically trying to think of a way to test that -Z no-landing-pads actually works (it was broken recently), so that's what this test is doing. The behavior is ARM-specific (from what I believe), so I think it's ok to just ignore it on android.

@bharrisau
Copy link
Contributor Author

Ahh, got you. Your test is making sure that it is behaving incorrectly, as opposed to correctly behaving unsafely. Well, if "undefined" is sufficient I'll xfail the test for android (just wish it failed more concretely than with an illegal instruction).

@alexcrichton
Copy link
Member

Upon rebasing LLVM it sounds like they're removing the arm-enable-ehabi option entirely. I think they turned it on by default for relevant platforms and I suppose they handle it somehow for others. See llvm-mirror/llvm@3fca788

I'm just waiting for LLVM's mingw bots to go green before we rebase and take an LLVM upgrade, but it could be a long time before that happens if they start requiring c++11 to build llvm (which they're definitely doing soon).

@alexcrichton alexcrichton mentioned this pull request Feb 12, 2014
@alexcrichton
Copy link
Member

Closing in favor of #12207 (llvm removed these options).

bors added a commit that referenced this pull request Feb 14, 2014
Includes an upstream commit by pcwalton to improve codegen of our enums getting
moved around.

This also introduces a new commit on top of our stack of patches to fix a mingw32 build issue. I have submitted the patch upstream: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140210/204653.html

I verified that this builds on the try bots, which amazes me because I think that c++11 is turned on now, but I guess we're still lucky!

Closes #10613 (pcwalton's patch landed)
Closes #11992 (llvm has removed these options)
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 4, 2024
…domDev99

fix suggestion for [`len_zero`] with macros

fixes: rust-lang#11992

changelog: fix suggestion for [`len_zero`] with macros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants