birdofpreyru / react-native-static-server

Embedded HTTP server for React Native
https://dr.pogodin.studio/docs/react-native-static-server
Other
135 stars 21 forks source link

Github actions build fails with `ld: error: --fix-cortex-a53-843419 is only supported on AArch64 targets` #112

Closed c-emil closed 1 month ago

c-emil commented 1 month ago

I'm facing the same issue you faced here: https://github.com/facebook/react-native/issues/38111

ld: error: --fix-cortex-a53-843419 is only supported on AArch64 targets
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /usr/local/lib/android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        /home/runner/work/react-native-wrapper/react-native-wrapper/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/RelWithDebInfo/2v344f24/arm64-v8a \
        lighttpd
    from /home/runner/work/react-native-wrapper/react-native-wrapper/node_modules/@dr.pogodin/react-native-static-server/android

3 months ago I was able to run the exact same build in github actions using the ubuntu-latest runner, now it fails with above error. I didn't change a single thing in the repo because I tried to run it with the same commit hash. The ubuntu-latest runner uses ubuntu 22.04.4, which, according to the docs, contains several CMAKE versions in the preinstalled Android SDK. As you can see in the above error it uses version 3.22.1 of cmake which should be, according to your docs fine.

I noticed one weird thing though. I'm using actions-setup-cmake github action, which should set the correct version of cmake for the os that's being used in the workflow:

 - name: Setup cmake needed for react-native-static-server build
        uses: jwlawson/actions-setup-cmake@v1.14.1
        with:
          cmake-version: '3.27.4'

When I use the 3.27.4 version, it uses 2.22.1 cmake from android sdk. However, if specify cmake-version to 3.22.1 it uses /usr/local/lib/android/sdk/cmake/3.18.1/bin/ninja instead. I'd understand that the build would fail with 3.18.1, but I don't understand why it fails when it uses 3.22.1. Also, I'm not sure why you use the sdk's version of cmake in your scripts and not the one that's set in the system's path.

I was thinking that if I somehow manage to tell the github action runner to use the android sdk's 2.22.1 version when I setup the cmake to 2.22.1 in the system's path, it would maybe fix the issue, but I honestly don't know to tell the runner to explicitly set the SDK version. In readme of the runner there are only 3 versions listed but no mention of how I could switch between each of them. I tried updating the app/build.gradle's android property:

android: {
    externalNativeBuild {
       cmake {
           version "3.22.1"
       }
}

with no success either. I'd appreciate any help or feedback.

birdofpreyru commented 1 month ago

Interesting! And I don't remember much details from the last time I looked into it. I had a brief look now, it seems what I wrote in https://github.com/facebook/react-native/issues/38111 did not quite work in some cases (https://github.com/birdofpreyru/react-native-static-server/issues/66, https://github.com/birdofpreyru/react-native-static-server/issues/67, https://github.com/birdofpreyru/react-native-static-server/issues/84), and in https://github.com/birdofpreyru/react-native-static-server/commit/22ae60b2f38bc764f350530aa949f9afcf90949f I reworked the way PCRE2 library is linked in; that's when set(PKG_CONFIG_ARGN --lib-only-l) was removed from CMakeLists.txt as redundant.


I guess, what happens in your case is that ubuntu-latest runner you use got updated, to include PCRE2 library (or to include it in a different manner than before), and now the build process finds and attempts to link that Ubuntu version of PCRE2, rather than its Android version, cross-compiled as a part of the static server library build. Perhaps, the cross-compilation fails now for some reason (look earlier in the logs) and it tries to fallback to the incorrect PCRE2 library on the build host?

So, I'd say, check https://github.com/birdofpreyru/react-native-static-server/blob/master/CMakeLists.txt, see to which path it is supposed to cross-compile Android version of PCRE2, check whether it has successfully build & placed it to the expected path, and if it did it, then we should figure out set(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/sysroot") did not forced CMake to pick that up.

c-emil commented 1 month ago

Thanks for the quick feedback! I really appreciate it. I'll first update the version of the package to 9.0.1 where you made the changes you mentioned above and see if it fixes the issue. If it doesn't, I'll investigate further. I'm using 0.8.4 now.

c-emil commented 1 month ago

Updating to 9.0.1 fixed the build issue for me. Thanks a lot!