Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build for BridgeSupport in Mac OS X 10.6 and 10.7 #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix build for BridgeSupport in Mac OS X 10.6 and 10.7 #2

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 17, 2013

This was accomplished by changing the compiler-rt code so that it avoids building for armv6 architectures whenever the target OS is Darwin.

Unfortunately, Clang is packed up in a zip file, so you can't see the diff without pulling and comparing yourself.

This does not fix the build for OS X 10.8. In 10.8, the process that creates all the BridgeSupport files for the current OS while running make is extremely unstable. You'll see it crash at least once. It will never complete successfully.

I do not know how it performs in 10.7, yet. If you'd like, I can set up a virtual machine and see.

@ghost
Copy link
Author

ghost commented May 17, 2013

To elaborate, this is the backtrace for the crash that always shows up when building under 10.8.

build.rb:169:in `run': exit status=1 (RuntimeError)
    from build.rb:161:in `open'
    from build.rb:161:in `run'
    from build.rb:158:in `loop'
    from build.rb:158:in `run'
    from build.rb:181
    from build.rb:181:in `initialize'
    from build.rb:181:in `new'
    from build.rb:181
    from build.rb:181:in `times'
    from build.rb:181

You'll typically see OS X catch this and report it as an exception of type EXC_BREAKPOINT (SIGTRAP).

Looks like it might be a string parsing issue with Ruby. Odd that it doesn't show up in 10.6. Maybe there's a framework in 10.8 (and possibly 10.7) that's disrupting this process?

I am not a Ruby developer, so I'm afraid I can't help out much more than that.

@ghost
Copy link
Author

ghost commented May 17, 2013

Wait, I did more digging.

Making a small change to build.rb to print each line to the terminal reveals the error.

Just change line 164 from this,

io.each { |line| sio << line }

To this,

io.each do |line| 
  print line
  sio << line 
end

Now we get a more elaborate backtrace, as shown below.

./gen_bridge_metadata.rb:604:in `_parse': No struct corresponding to CGSize (RuntimeError)
    from ./gen_bridge_metadata.rb:602:in `each'
    from ./gen_bridge_metadata.rb:602:in `_parse'
    from ./gen_bridge_metadata.rb:731:in `parse'
    from build.rb:45:in `work'
    from build.rb:18:in `measure'
    from build.rb:45:in `work'
    from build.rb:74
build.rb:172:in `run': exit status=1 (RuntimeError)
    from build.rb:161:in `open'
    from build.rb:161:in `run'
    from build.rb:158:in `loop'
    from build.rb:158:in `run'
    from build.rb:184
    from build.rb:184:in `initialize'
    from build.rb:184:in `new'
    from build.rb:184
    from build.rb:184:in `times'
    from build.rb:184

It seems BridgeSupport doesn't know how to handle CGSize, from CoreGraphics. As I recall, Apple moved CoreGraphics in 10.8. That's probably the root cause of our problem.

Now, if somebody could figure out how to tell BridgeSupport to symbolicate CGSize, among other CoreGraphics structs, enumerations and C symbols, we'll be off to the races.

@ghost
Copy link
Author

ghost commented May 17, 2013

Alright, after doing much more work than I should have done on this, it seems that BridgeSupport's exception files — XML listings of predefined C structures, C functions and C macros — will have to be updated for 10.8.

There's a number of entries in the exception files contained within BridgeSupport that simply don't exist as part of the Cocoa API for 10.8. They've been deprecated for so long that they're now nonexistent.

CoreGraphics still has trouble. While there are some C functions and structures present in the exception files that are no longer available in 10.8, it also has a very unique problem. CGSize, CGRect, CGPoint, and CGAffineTransform aren't being being recognized as C structures by the parser defined by gen_bridge_metadata.rb. Not good.

To really update BridgeSupport for 10.8 is going to require a bit of persistence, just to work through each of the issues.

In addition, making those changes without any additional modifications to the Ruby scripts and the Makefiles would break support for 10.6. BridgeSupport's exception files don't appear to have any means of supporting different versions of OS X. At best, it retrieves what kernel architecture Ruby was built for as a string, and looks up a folder of exception files based on that string before it proceeds to do its dirty work.

There's also a seemingly random crash while generating BridgeSupport files during the make process in 10.8. On top of the Ruby exception throwing that occurs when there was a problem parsing a framework, there's another crash that happens during parsing... and that one does not stop the make process cold. I've tried reducing the concurrency to only dispatch one background thread at a time, in hopes that it might help fix the problem or isolate it to a specific place. That didn't make a difference. This particular issue makes me nervous about how future proof this code is, in its current state.

Given the issues present, I'm going to leave BridgeSupport with the fixes I've made so far, and let somebody else have the opportunity to make those fixes for 10.8. It's not going to be a small patch, I'll tell you that.

Feel free to merge this in, if you have time. Let me know if you have any questions, otherwise.

@ghost
Copy link
Author

ghost commented May 22, 2013

That takes care of OS X 10.7.

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.

0 participants