MobiVM / robovm

Ahead of time compiler for JVM bytecode targetting iOS, Mac OSX and Linux
https://mobivm.github.io
967 stars 133 forks source link

Linker Error from Gradle Build in Layout.cpp in Mac OS Sonoma 14.0. #752

Closed andreas-stefik closed 1 year ago

andreas-stefik commented 1 year ago

Please use discussions for all things that are not reportable issues.

Please ensure you have given all the following requested information in your report.

Issue details

Hello there. We have a custom stack that uses MobiVM internally. After upgrading to sonoma, with no changes as far as we can tell, we are now getting the following error:

0 0x104142f43 assert_rtn + 64 1 0x1040ead4b void dispatchForEach<mach_o::CompactUnwind::Diff24Fixup const, ld::LayoutExecutable::writeCompactUnwind(std::1::span<unsigned char, 18446744073709551615ul>, unsigned long long, ld::SectionLayout const&) const::$_26>(std::1::span<mach_o::CompactUnwind::Diff24Fixup const, 18446744073709551615ul>, unsigned long, ld::LayoutExecutable::writeCompactUnwind(std::__1::span<unsigned char, 18446744073709551615ul>, unsigned long long, ld::SectionLayout const&) const::$_26)::'lambda'(unsigned long)::operator()(unsigned long) const + 347 2 0x7ff8174415cd _dispatch_client_callout2 + 8 3 0x7ff81745319d _dispatch_apply_invoke_and_wait + 214 4 0x7ff8174526ab _dispatch_apply_with_attr_f + 1181 5 0x7ff81745285f dispatch_apply + 45 6 0x1040eb116 ld::LayoutExecutable::writeContentWithoutLinkEdit(std::1::span<unsigned char, 18446744073709551615ul>, unsigned long long) + 950 7 0x1040f29fa ld::LayoutExecutable::writeToFile(char const*) + 21546 8 0x104091f9f main + 12831 ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758. clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproduction steps/code

Our stack is open source and I can walk through reproducing it, but it's quite complicated to do so. I figure I will toss the error in first

Configuration

We are using our own custom stack. It's always worked just fine, using gradle as a backend. We are using 2.3.20.

Build Tools:

Versions:

Please provide the version of RoboVM, XCode and JDK used

Robovm 2.3.20 XCode 15.0. So far as I can tell, this only happens on the latest version JDK 8

We still use 8 as I recall MobiVM used to only allow up to that. I don't know if 11 or above was supported later.

Build Targets:

Please provide the build targets this issue is seen on if applicable. e.g. iPhone 4s Simulator 32bit

IPhone 15 simulator.


Stacktrace

//Please provide the stacktrace if applicable 

0 0x104142f43 assert_rtn + 64 1 0x1040ead4b void dispatchForEach<mach_o::CompactUnwind::Diff24Fixup const, ld::LayoutExecutable::writeCompactUnwind(std::1::span<unsigned char, 18446744073709551615ul>, unsigned long long, ld::SectionLayout const&) const::$_26>(std::1::span<mach_o::CompactUnwind::Diff24Fixup const, 18446744073709551615ul>, unsigned long, ld::LayoutExecutable::writeCompactUnwind(std::__1::span<unsigned char, 18446744073709551615ul>, unsigned long long, ld::SectionLayout const&) const::$_26)::'lambda'(unsigned long)::operator()(unsigned long) const + 347 2 0x7ff8174415cd _dispatch_client_callout2 + 8 3 0x7ff81745319d _dispatch_apply_invoke_and_wait + 214 4 0x7ff8174526ab _dispatch_apply_with_attr_f + 1181 5 0x7ff81745285f dispatch_apply + 45 6 0x1040eb116 ld::LayoutExecutable::writeContentWithoutLinkEdit(std::1::span<unsigned char, 18446744073709551615ul>, unsigned long long) + 950 7 0x1040f29fa ld::LayoutExecutable::writeToFile(char const*) + 21546 8 0x104091f9f main + 12831 ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758. clang: error: linker command failed with exit code 1 (use -v to see invocation)

We do have native code in ours, but don't see anything relevant to a Layout.cpp file in our build. I've tried the obvious things, like just re-compiling it, but everything works how I expect. I have a hunch this is a bug and I figured I had better report it.

andreas-stefik commented 1 year ago

It's possible IOS 17 bindings just aren't in there yet and that's what I'm seeing, but I can't tell from the linker error. If so, sorry to bother.

dkimitsa commented 1 year ago

hi, duplicate of https://github.com/MobiVM/robovm/issues/750 its Xcode15 issue, check #750 above for solution

andreas-stefik commented 1 year ago

Oh lovely. I'll give this a shot and thank you!

andreas-stefik commented 1 year ago

Does the flag have to go somewhere specific? It doesn't seem to like the recommended fix. I apologize if this is a dumb question.

<config>
  <mainJar>jars/Default.jar</mainJar>
  <os>ios</os>
  <arch>thumbv7</arch>
  <target>ios</target>

  <resources>
    <resource>
      <directory>media</directory>
      <targetPath>media</targetPath>
    </resource>
  </resources>
  <tools>
      <linker>
          <flags>
              <flag>-ld_classic</flag>
          </flags>
      </linker>
  </tools>
  <classpath>
    <classpathentry>jars/Default.jar</classpathentry>
    <classpathentry>jars/QuorumStandardLibrary.jar</classpathentry>
    <classpathentry>jars/QuorumStandardPlugins.jar</classpathentry>
  </classpath>
  <libs>
    <lib>natives/iosSimulator.a</lib>
  </libs>
  <weakFrameworks>
    <framework>OpenGLES</framework>
    <framework>UIKit</framework>
    <framework>QuartzCore</framework>
    <framework>CoreGraphics</framework>
    <framework>OpenAL</framework>
    <framework>AudioToolbox</framework>
    <framework>AVFoundation</framework>
  </weakFrameworks>
  <iosInfoPList>Info.plist.xml</iosInfoPList>
</config>
andreas-stefik commented 1 year ago

Looks like it's giving me this:


Caused by: org.gradle.api.GradleException: Failed to read project RoboVM config file in /Users/stefik/Quorum Studio/PhoneTestLatest/Run/Mobile/ios
        at org.robovm.gradle.tasks.AbstractRoboVMTask.configure(AbstractRoboVMTask.java:157)
        at org.robovm.gradle.tasks.AbstractRoboVMTask.build(AbstractRoboVMTask.java:96)
        at org.robovm.gradle.tasks.AbstractSimulatorTask.launch(AbstractSimulatorTask.java:37)
        ... 124 more
Caused by: java.io.IOException: org.simpleframework.xml.core.ElementException: Element 'linker' does not have a match in class org.robovm.compiler.config.tools.Tools at line 32
        at org.robovm.compiler.config.Config$Builder.read(Config.java:1794)
        at org.robovm.compiler.config.Config$Builder.read(Config.java:1783)
        at org.robovm.compiler.config.Config$Builder.readProjectConfig(Config.java:1777)
        at org.robovm.gradle.tasks.AbstractRoboVMTask.configure(AbstractRoboVMTask.java:153)
        ... 126 more
Caused by: org.simpleframework.xml.core.ElementException: Element 'linker' does not have a match in class org.robovm.compiler.config.tools.Tools at line 32
        at org.simpleframework.xml.core.Composite.readElement(Composite.java:527)
        at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
        at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
        at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
        at org.simpleframework.xml.core.Composite.read(Composite.java:201)
        at org.simpleframework.xml.core.Composite.read(Composite.java:148)
        at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623)
        at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
        at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
        at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
        at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
        at org.simpleframework.xml.core.Composite.readSection(Composite.java:327)
        at org.simpleframework.xml.core.Composite.read(Composite.java:306)
        at org.simpleframework.xml.core.Composite.read(Composite.java:172)
        at org.simpleframework.xml.core.Traverser.read(Traverser.java:120)
        at org.simpleframework.xml.core.Persister.read(Persister.java:872)
        at org.simpleframework.xml.core.Persister.read(Persister.java:852)
        at org.simpleframework.xml.core.Persister.read(Persister.java:829)
        at org.simpleframework.xml.core.Persister.read(Persister.java:806)
        at org.simpleframework.xml.core.Persister.read(Persister.java:701)
        at org.robovm.compiler.config.Config$Builder.read(Config.java:1790)
        ... 129 more
andreas-stefik commented 1 year ago

Shoot my bad. Turns out this is what I get when I use .18. Upgrading the dependency to .20 fixes it. I'll close this out and thank you for your help. This workaround did work.

ollyde commented 1 year ago

Caused by: org.simpleframework.xml.core.ElementException: Element 'linker' does not have a match in class org.robovm.compiler.config.tools.Tools at line 9

Doesn't seem to work for me, there's no tools being picked up by the XML ios/robovm.xml

dkimitsa commented 1 year ago

@ollyde it was added in 2.3.20, make sure you have updated you gradle settings and idea plugin

ollyde commented 1 year ago

I'm using roboVMVersion = '2.3.20' and still seeing the error @dkimitsa

Screenshot 2023-10-31 at 14 36 34
dkimitsa commented 1 year ago

if you run it in Idea/Android studio (from the screen shot it looks like this) -- you have to update MobiVM plugin for Idea as well (pick it from market place or install directly from https://mobivm.github.io/dev/.

ollyde commented 1 year ago

@dkimitsa I have the latest installed, Android studio

Screenshot 2023-10-31 at 15 07 34
dkimitsa commented 1 year ago

ok, thx.

so few questions:

ollyde commented 1 year ago

Thanks for helping @dkimitsa

I run from Android Studio, it's an old LibGDX project (for a very popular video game)

My robovm.xml looks like so

<config>
  <executableName>${app.executable}</executableName>
  <mainClass>${app.mainclass}</mainClass>
  <os>ios</os>
  <target>ios</target>
  <iosInfoPList>Info.plist.xml</iosInfoPList>
  <treeShaker>conservative</treeShaker>
  <resources>
    <resource>
      <directory>../assets</directory>
      <includes>
        <include>**</include>
      </includes>
      <skipPngCrush>true</skipPngCrush>
    </resource>
    <resource>
      <directory>data</directory>
    </resource>
  </resources>
  <tools>
    <linker>
      <flags>
        <flag>-ld_classic</flag>
      </flags>
    </linker>
  </tools>
  <forceLinkClasses>
    <pattern>com.badlogic.gdx.scenes.scene2d.ui.*</pattern>
    <pattern>com.badlogic.gdx.graphics.g3d.particles.**</pattern>
    <pattern>com.android.okhttp.HttpHandler</pattern>
    <pattern>com.android.okhttp.HttpsHandler</pattern>
    <pattern>com.android.org.conscrypt.**</pattern>
    <pattern>com.android.org.bouncycastle.jce.provider.BouncyCastleProvider</pattern>
    <pattern>com.android.org.bouncycastle.jcajce.provider.keystore.BC$Mappings</pattern>
    <pattern>com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi</pattern>
    <pattern>com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$Std</pattern>
    <pattern>com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi</pattern>
    <pattern>com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL</pattern>
    <pattern>org.apache.harmony.security.provider.cert.DRLCertFactory</pattern>
    <pattern>org.apache.harmony.security.provider.crypto.CryptoProvider</pattern>
  </forceLinkClasses>
  <libs>
      <lib>z</lib>   
  </libs>
  <frameworks>
    <framework>UIKit</framework>
    <framework>QuartzCore</framework>
    <framework>CoreGraphics</framework>
    <framework>OpenAL</framework>
    <framework>AudioToolbox</framework>
    <framework>AVFoundation</framework>
    <framework>GameController</framework>
  </frameworks>
</config>
dkimitsa commented 1 year ago

I run from Android Studio, it's an old LibGDX project (for a very popular video game) that is the question how exactly you run it there ? are you using run configuration ?

if you receive error during the build -- you should have see an error in run configuration as well (like no robovm module detected) . and you should not be able to run it.

btw, checked your robovm.xml -- works for me.

ollyde commented 1 year ago

@dkimitsa yeah I don't know. Everything is updated to the version you have specified, but I still get

[ERROR] Couldn't load robovm.xml
java.io.IOException: org.simpleframework.xml.core.ElementException: Element 'linker' does not have a match in class org.robovm.compiler.config.tools.Tools at line 21
    at org.robovm.compiler.config.Config$Builder.read(Config.java:1782)
    at org.robovm.compiler.config.Config$Builder.read(Config.java:1771)
    at org.robovm.compiler.config.Config$Builder.readProjectConfig(Config.java:1765)
ollyde commented 1 year ago

@dkimitsa seems there's a bug in Android Studio, it was showing 2.3.20 but it was actually 2.3.19 looking at the files and cache from the plugin library, that is CRAZY. Good thing I only have to open this garbage to fix this 😂