Skip to content

[Regression] Build fails on Linux Armv7 #61965

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

Open
colemancda opened this issue Nov 7, 2022 · 43 comments
Open

[Regression] Build fails on Linux Armv7 #61965

colemancda opened this issue Nov 7, 2022 · 43 comments
Labels
armv7 Architecture: ARMv7 bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. build error Errors when building the toolchain, not regular Swift code Linux Platform: Linux

Comments

@colemancda
Copy link
Contributor

colemancda commented Nov 7, 2022

Describe the bug
I am trying to compile Swift with the buildbot_linux,no_test preset and the build fails.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Clone and Swift 5.7.1 sources on Debian 11 Armhf
  2. Build with ./swift/utils/build-script --preset=buildbot_linux,no_test
    ...

Expected behavior
The build process should not fail. This previously worked with Swift 5.1.5.

Environment (please fill out the following information)

  • OS: Debian Bullseye armhf
  • Swift: swift-5.7.1-RELEASE

Additional context

swift-linux-armv7.log

Running on CTL J4+ Chromebook with Cadmium.

Screenshot 2022-11-07 at 1 54 11 PM

@colemancda colemancda added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Nov 7, 2022
@colemancda
Copy link
Contributor Author

@buttaface Do you have any patches to deal with the libdispatch build errors on Android Armv7?

@colemancda
Copy link
Contributor Author

I was able to get past the libdispatch failure with --extra-cmake-options='-DCMAKE_C_FLAGS="-w" -DCMAKE_CXX_FLAGS="-w"'

coleman@ctl-j4:~/Developer/swift-source$ ./swift/utils/build-script --assertions --swift-enable-ast-verifier=0 --no-swift-stdlib-assertions '--swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;static-mirror-lib;toolchain-tools;license;sourcekit-inproc' '--llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file' --llbuild --swiftpm --swift-driver --xctest --libicu --swiftdocc --build-ninja --install-llvm --install-swift --install-lldb --install-llbuild --install-swiftpm --install-swift-driver --install-xctest --install-libicu --install-prefix=/usr --install-sourcekit-lsp --install-swiftdocc --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-swift-stdlib-unittest-extra --test-installable-package --toolchain-benchmarks --install-destdir=/home/coleman/Developer/swift-source/install --installable-package=/home/coleman/Developer/swift-source/install/swift-5.7.1-armv7-RELEASE-Debian11.tar.gz --relocate-xdg-cache-home-under-build-subdir --build-subdir=buildbot_linux --lldb --release --test --validation-test --long-test --stress-test --test-optimized --foundation --libdispatch --indexstore-db --sourcekit-lsp --skip-test-sourcekit-lsp --swiftdocc '--lit-args=-v --time-tests' --lldb-test-swift-only --install-foundation --install-libdispatch --reconfigure --skip-test-cmark --skip-test-lldb --skip-test-swift --skip-test-llbuild --skip-test-swiftpm --skip-test-swift-driver --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-playgroundsupport --skip-test-libicu --skip-test-indexstore-db --skip-test-sourcekit-lsp --skip-test-swiftdocc  --extra-cmake-options='-DCMAKE_C_FLAGS="-w" -DCMAKE_CXX_FLAGS="-w"'

@AnthonyLatsis AnthonyLatsis added Linux Platform: Linux armv7 Architecture: ARMv7 build error Errors when building the toolchain, not regular Swift code labels Nov 7, 2022
@finagolfin
Copy link
Member

No, this seems specific to glibc/armv7, I have not seen it with bionic/armv7, which built fine last week (I have not run that 5.7.1 armv7 build yet, but 5.7 mostly worked fine). I did make other modifications for 32-bit ARM with the 5.7 update, such as turning bootstrapping off because the resulting compiler segfaults.

I also had to modify trunk last month, one of which @eeckstein later remedied in #61868.

@colemancda
Copy link
Contributor Author

@buttaface From what I understood looking at your Termux build script, you are cross compiling from x86_64 to Armv7, and relying on the official Ubuntu releases, that's also how you are able to disable bootstrapping, because you already have an existing compiler.

@finagolfin
Copy link
Member

Yes, but there's no need for that official host x86_64 Swift compiler to cross-compile the Swift compiler itself for armv7 once you disable bootstrapping. I do use the official host x86_64 Swift compiler to then cross-compile the stdlib and the rest of the toolchain, but if you're building natively on armv7, you can just use the natively-built compiler with bootstrapping similarly turned off. In other words, turning bootstrapping off should work no matter what.

@colemancda
Copy link
Contributor Author

colemancda commented Nov 8, 2022

Ok, I will try both approaches. Thanks for the info. I also wanted to know are all the patches in that swift package folder being applied? Or only some? Which ones besides https://github.com/termux/termux-packages/blob/master/packages/swift/swift-include-swift-AST-Expr.h.patch ?

@finagolfin
Copy link
Member

Yes, all of them, though most are specific to Android and so will not be relevant to linux armv7.

@colemancda
Copy link
Contributor Author

colemancda commented Nov 8, 2022

After applying patches and building with

--extra-cmake-options='-DCMAKE_C_FLAGS="-w" -DCMAKE_CXX_FLAGS="-w"'
--bootstrapping=off

I get the following error:

/home/coleman/Developer/swift-source/build/buildbot_linux/swift-linux-armv7/stdlib/public/core/4/Tuple.swift
/home/coleman/Developer/swift-source/build/buildbot_linux/swift-linux-armv7/stdlib/public/core/4/SIMDConcreteOperations.swift
/home/coleman/Developer/swift-source/build/buildbot_linux/swift-linux-armv7/stdlib/public/core/4/SIMDVectorTypes.swift
---
4.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for Swift)
5.      While running pass #174401 SILFunctionTransform "PredictableDeadAllocationElimination" on SILFunction "@$ss7UnicodeO12_InternalNFCV8IteratorV13composeHangul_3andAB6ScalarVSgAJ_AJtF".
 for 'composeHangul(_:and:)' (at /home/coleman/Developer/swift-source/swift/stdlib/public/core/NFC.swift:63:12)
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
[372/621][ 59%][4415.763s] Linking CXX executable bin/sil-func-extractor
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

@finagolfin
Copy link
Member

Huh, that's strange: you built the Swift compiler natively but it couldn't build the stdlib, even though it works when cross-compiling the stdlib? Could you check and see if bootstrapping is really turned off, either by running readelf -d build/Ninja-Release/swift-linux-armv7/bin/swift-frontend or ag bootstrap build/Ninja-Release/swift-linux-armv7/CMakeCache.txt?

@colemancda
Copy link
Contributor Author

coleman@ctl-j4:~/Developer/swift-source$ readelf -d build/buildbot_linux/swift-linux-armv7/bin/swift-frontend

Dynamic section at offset 0x8c74eb4 contains 36 entries:
  Tag        Type                         Name/Value
 0x00000003 (PLTGOT)                     0x8c99eb0
 0x00000002 (PLTRELSZ)                   2864 (bytes)
 0x00000017 (JMPREL)                     0xd0b0
 0x00000014 (PLTREL)                     REL
 0x00000011 (REL)                        0xcfb0
 0x00000012 (RELSZ)                      256 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000006 (SYMTAB)                     0x81f4
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000005 (STRTAB)                     0x9a14
 0x0000000a (STRSZ)                      9630 (bytes)
 0x6ffffef5 (GNU_HASH)                   0xbfb4
 0x00000004 (HASH)                       0xc000
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libatomic.so.1]
 0x00000001 (NEEDED)                     Shared library: [libuuid.so.1]
 0x00000001 (NEEDED)                     Shared library: [librt.so.1]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libtinfo.so.6]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
 0x0000000c (INIT)                       0xdbe0
 0x0000000d (FINI)                       0x600feb8
 0x0000001a (FINI_ARRAY)                 0x87eb328
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000019 (INIT_ARRAY)                 0x87eb32c
 0x0000001b (INIT_ARRAYSZ)               2132 (bytes)
 0x0000001d (RUNPATH)                    Library runpath: [/home/coleman/Developer/swift-source/build/buildbot_linux/llvm-linux-armv7/./lib:]
 0x6ffffff0 (VERSYM)                     0xca2c
 0x6ffffffe (VERNEED)                    0xcd30
 0x6fffffff (VERNEEDNUM)                 9
 0x00000000 (NULL)                       0x0

@colemancda
Copy link
Contributor Author

/home/coleman/Developer/swift-source/build/buildbot_linux/swift-linux-armv7/CMakeCache.txt

//How to build the swift compiler modules. Possible values are
//\n    OFF:           build without swift modules
//\n    HOSTTOOLS:     build with a pre-installed toolchain
//\n    BOOTSTRAPPING: build with a 2-stage bootstrapping process
//\n    BOOTSTRAPPING-WITH-HOSTLIBS:   build with a 2-stage bootstrapping
// process,
//\n                   but the compiler links against the host system
// swift libs (macOS only)
//\n    CROSSCOMPILE:  cross-compiledwith a native host compiler,
// provided in
//\n                   `SWIFT_NATIVE_SWIFT_TOOLS_PATH` (non-Darwin
// only)
//\n    CROSSCOMPILE-WITH-HOSTLIBS:    build with a bootstrapping-with-hostlibs
// compiled
//\n                                   compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`
//\n
BOOTSTRAPPING_MODE:STRING=OFF

@finagolfin
Copy link
Member

OK, so it is turned off. One other difference is that I almost always build in release mode with assertions turned off, but you appear to have assertions enabled above. Maybe that's the reason you're seeing this crash?

@colemancda
Copy link
Contributor Author

@buttaface I will try that, but if that doesn't work I am just gonna have to try to cross compile everything, which is gonna involve more custom scripting to setup. This build is basically a modified buildbot_linux,no_test with some extra flags.

@colemancda
Copy link
Contributor Author

Building with

./swift/utils/build-script -RA --swift-enable-ast-verifier=0 --no-swift-stdlib-assertions '--swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;static-mirror-lib;toolchain-tools;license;sourcekit-inproc' '--llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file' --llbuild --swiftpm --swift-driver --xctest --libicu --swiftdocc --build-ninja --install-llvm --install-swift --install-lldb --install-llbuild --install-swiftpm --install-swift-driver --install-xctest --install-libicu --install-prefix=/usr --install-sourcekit-lsp --install-swiftdocc --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-swift-stdlib-unittest-extra --test-installable-package --toolchain-benchmarks --install-destdir=/home/coleman/Developer/swift-source/install --installable-package=/home/coleman/Developer/swift-source/install/swift-5.7.1-armv7-RELEASE-Debian11.tar.gz --relocate-xdg-cache-home-under-build-subdir --build-subdir=buildbot_linux --lldb --release --test --validation-test --long-test --stress-test --test-optimized --foundation --libdispatch --indexstore-db --sourcekit-lsp --skip-test-sourcekit-lsp --swiftdocc '--lit-args=-v --time-tests' --lldb-test-swift-only --install-foundation --install-libdispatch --reconfigure --skip-test-cmark --skip-test-lldb --skip-test-swift --skip-test-llbuild --skip-test-swiftpm --skip-test-swift-driver --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-playgroundsupport --skip-test-libicu --skip-test-indexstore-db --skip-test-sourcekit-lsp --skip-test-swiftdocc  --extra-cmake-options='-DCMAKE_C_FLAGS="-w" -DCMAKE_CXX_FLAGS="-w"' --bootstrapping=off

@finagolfin
Copy link
Member

The only flag I might change is to patch the place where libdispatch is configured with the stdlib directly and remove the --extra-cmake-options flags, which will be applied everywhere. You can also use --libdispatch-cmake-options and the like to add flags for specific subsequent corelibs builds if needed.

@colemancda
Copy link
Contributor Author

Building with -RA I get

/home/coleman/Developer/swift-source/build/buildbot_linux/swift-linux-armv7/stdlib/public/core/4/SIMDConcreteOperations.swift
/home/coleman/Developer/swift-source/build/buildbot_linux/swift-linux-armv7/stdlib/public/core/4/SIMDVectorTypes.swift
---
4.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for Swift)
5.      While running pass #184556 SILFunctionTransform "PredictableMemoryAccessOptimizations" on SILFunction "@$ss13_StringObjectV13CountAndFlagsV5count7isASCII0G3NFC0G14NativelyStored0G13TailAllocatedADSi_S4btcfC".
 for 'init(count:isASCII:isNFC:isNativelyStored:isTailAllocated:)' (at /home/coleman/Developer/swift-source/swift/stdlib/public/core/StringObject.swift:742:12)
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
[1148/1400][ 82%][9382.044s] Building CXX object tools/sil-passpipeline-dumper/CMakeFiles/sil-passpipeline-dumper.dir/SILPassPipelineDumper.cpp.o
^C
ninja: build stopped: interrupted by user.

@colemancda
Copy link
Contributor Author

When cross compiling, LLVM is failing to build:
https://github.com/colemancda/swift-armv7/blob/feature/compiler/build-swift-compiler.sh

./utils/build-script -RA \
    --reconfigure \
    --skip-early-swift-driver \
    --bootstrapping=off \
    --build-toolchain-only \
    --skip-local-build \
    --skip-local-host-install \
    --native-swift-tools-path=$SWIFT_NATIVE_PATH \
    --native-clang-tools-path=$SWIFT_NATIVE_PATH \
    --cross-compile-hosts=linux-armv7 \
    --cross-compile-deps-path=$STAGING_DIR \
    --cross-compile-append-host-target-to-destdir=False \
    --swift-install-components='autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay' \
    --install-swift \
    --install-cmark \
    --install-destdir=$SWIFT_INSTALL_PREFIX \
    --build-dir=$SRC_ROOT/build \
    --workspace=$SRC_ROOT/downloads \
    --extra-cmake-options=" \
        -DCMAKE_C_FLAGS=\"${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}\" \
        -DCMAKE_CXX_FLAGS=\"${RUNTIME_FLAGS} ${EXTRA_INCLUDE_FLAGS}\" \
        -DCMAKE_C_LINK_FLAGS=\"${LINK_FLAGS}\" \
        -DCMAKE_CXX_LINK_FLAGS=\"${LINK_FLAGS}\" \
        -DCMAKE_SYSROOT=\"$STAGING_DIR\" \
        -DCMAKE_LINKER=/usr/bin/ld.lld \
        -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_PATH=${STAGING_DIR} \
        -DSWIFT_SDK_LINUX_ARCH_${SWIFT_TARGET_ARCH}_LIBC_INCLUDE_DIRECTORY=${STAGING_DIR}/usr/include \
        -DSWIFT_USE_LINKER=lld \
        -DLLVM_USE_LINKER=lld \
        -DZLIB_LIBRARY=${STAGING_DIR}/usr/lib/arm-linux-gnueabihf/libz.so \
        -DZLIB_INCLUDE_DIR=${STAGING_DIR}/usr/include \
        -DSWIFT_PATH_TO_CMARK_BUILD=${SRC_ROOT}/downloads/build/Ninja-Release/cmark-linux-armv7 \
    "
[2600/3763][ 69%][375.069s] Linking CXX static library lib/libclangToolingASTDiff.a
[5282](swift-armv7/-/jobs/3293998813#L5282)[2601/3763][ 69%][375.169s] Linking CXX static library lib/libclangRewriteFrontend.a
[5283](swift-armv7/-/jobs/3293998813#L5283)[2602/3763][ 69%][375.173s] Linking CXX static library lib/libclangARCMigrate.a
[5284](swift-armv7/-/jobs/3293998813#L5284)[2603/3763][ 69%][375.182s] Linking CXX static library lib/libclangCodeGen.a
[5285](swift-armv7/-/jobs/3293998813#L5285)[2604/3763][ 69%][375.665s] Linking CXX executable bin/clang-ast-dump
[5286](swift-armv7/-/jobs/3293998813#L5286)[2605/3763][ 69%][375.725s] ASTNodeAPI.json
[5287](swift-armv7/-/jobs/3293998813#L5287)FAILED: tools/clang/lib/Tooling/ASTNodeAPI.json /usr/src/swift-armv7/build/llvm-linux-armv7/tools/clang/lib/Tooling/ASTNodeAPI.json 
[5288](swift-armv7/-/jobs/3293998813#L5288)cd /usr/src/swift-armv7/build/llvm-linux-armv7/tools/clang/lib/Tooling && /usr/src/swift-armv7/build/llvm-linux-armv7/bin/clang-ast-dump --skip-processing=0 -I /usr/src/swift-armv7/build/llvm-linux-armv7/lib/clang/13.0.0/include -I /usr/src/swift-armv7/downloads/llvm-project/llvm/../clang/include -I /usr/src/swift-armv7/build/llvm-linux-armv7/tools/clang/include -I /usr/src/swift-armv7/build/llvm-linux-armv7/include -I /usr/src/swift-armv7/downloads/llvm-project/llvm/include -I /usr/src/swift-armv7/bullseye-armv7/usr/include/c++/9 -I /usr/src/swift-armv7/bullseye-armv7/usr/include/arm-linux-gnueabihf/c++/9 -I /usr/src/swift-armv7/bullseye-armv7/usr/include/c++/9/backward -I /usr/lib/clang/13.0.0/include -I /usr/src/swift-armv7/bullseye-armv7/usr/include/arm-linux-gnueabihf -I /usr/src/swift-armv7/bullseye-armv7/usr/include --json-output-path /usr/src/swift-armv7/build/llvm-linux-armv7/tools/clang/lib/Tooling/ASTNodeAPI.json
[5289](swift-armv7/-/jobs/3293998813#L5289)/lib/ld-linux-armhf.so.3: No such file or directory

@colemancda
Copy link
Contributor Author

So, I managed to cross compile swift-frontend and still getting the same error.

@finagolfin
Copy link
Member

Try the native build without --extra-cmake-options but with the replacement tweaks I mentioned, as you're bluntly overriding the C/C++ flags for all the repos, including LLVM, when applying that flag.

@colemancda
Copy link
Contributor Author

Unable to cross compile sourcekit-lsp

Generating a SwiftPM cross-compilation JSON file for linux is not supported yet

@finagolfin
Copy link
Member

Yeah, cross-compiling parts of the toolchain using SPM hasn't been configured in trunk yet, other than for macOS and Android. Does the Swift compiler you cross-compiled for linux armv7 run now?

@colemancda
Copy link
Contributor Author

I was able to cross compile everything with minor changes and patches. Building natively is still not working for me.

Screenshot 2022-11-12 at 9 33 32 PM

@finagolfin
Copy link
Member

Huh, that's funny, is there something substantially different about the clang toolchain you're using to natively compile the Swift compiler versus the one you're using to cross-compile it? What did you change from before, when you cross-compiled swift-frontend and it didn't work?

If you want to cross-compile sourcekit-lsp, you'll want to generate an SPM JSON file, like I did for Android. You could also try supplying the cross-compiled toolchain up through SPM to the native build, then only build the SPM-configured portions of the toolchain natively.

@colemancda
Copy link
Contributor Author

--- Building sourcekitlsp ---
+ /home/coleman/Developer/swift-armv7/downloads/sourcekit-lsp/Utilities/build-script-helper.py build --package-path /home/coleman/Developer/swift-armv7/downloads/sourcekit-lsp --build-path /home/coleman/Developer/swift-armv7/downloads/build/Ninja-Release/sourcekitlsp-linux-armv7 --configuration release --toolchain /usr --ninja-bin /usr/bin/ninja --cross-compile-host linux-armv7 --cross-compile-config /home/coleman/Developer/swift-armv7/build/swift-linux-armv7-install/usr/swiftpm.json
--- build-script-helper.py: error: cannot cross-compile for linux-armv7
ERROR: command terminated with a non-zero exit status 1, aborting

@finagolfin
Copy link
Member

If you want to cross-compile, you'll need to modify those build-script-helpers too, swiftlang/sourcekit-lsp#424. Note that many other toolchain repos, like swift-docc, do not support anything other than macOS cross-compilation, so native may be your best bet if you want a lot of those.

@colemancda
Copy link
Contributor Author

@buttaface I was able to cross compile everything, but sourcekit-lsp is crashing with VS Code (remote).

2022-11-12 23:33:18.174 sourcekit-lsp[1442:ad4fe1e0] could not open compilation database for /home/coleman/Developer/swift-armv7/swift-hello/Sources/swift-hello/Hello.swift
sourcekit-lsp: /home/coleman/Developer/swift-armv7/downloads/indexstore-db/lib/Database/Database.cpp:263: IndexStoreDB::db::UnitInfo IndexStoreDB::db::Database::Implementation::getUnitInfo(IndexStoreDB::db::IDCode, lmdb::txn &): Assertion `llvm::alignmentAdjustment(ptr, alignof(IDCode)) == 0 && "misaligned IDCode"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.

@finagolfin
Copy link
Member

Sourcekit-lsp has to be built with indexstore-db, and either that or SPM relied on libIndexStore.so (which is why I install that alone from the LLVM build in the Termux package), so make sure both are built and that library is installed in your toolchain.

@colemancda
Copy link
Contributor Author

It is, that is not the issue. libIndexStore.so is build and being used with swift test

@finagolfin
Copy link
Member

Huh, could be a genuine alignment issue on 32-bit armv7 then, Assertion llvm::alignmentAdjustment(ptr, alignof(IDCode)) == 0 && "misaligned IDCode"' failed. While I provide sourcekit-lsp as part of the Termux package for Android armv7, I've never actually tested it on armv7 and it's possible it's broken there too.

@colemancda
Copy link
Contributor Author

colemancda commented Nov 14, 2022

The cross compiled swiftc can build packages in debug configuration just fine. But building with release configuration always crashes. If we could solve this we could build the entire Swift compiler suite natively instead of cross compiling.

https://github.com/PureSwift/Bluetooth/actions/runs/3458951709/jobs/5777868385

Building for production...
[8](https://github.com/PureSwift/Bluetooth/actions/runs/3458951709/jobs/5777868385#step:6:9)
malloc(): invalid next size (unsorted)

1.	Swift version 5.7.1 (swift-5.7.1-RELEASE)
[13](https://github.com/PureSwift/Bluetooth/actions/runs/3458951709/jobs/5777868385#step:6:14)
2.	Compiling with the current language version
[14](https://github.com/PureSwift/Bluetooth/actions/runs/3458951709/jobs/5777868385#step:6:15)
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for Bluetooth)
[15](https://github.com/PureSwift/Bluetooth/actions/runs/3458951709/jobs/5777868385#step:6:16)
4.	While running pass #39500 SILFunctionTransform "SILCombine" on SILFunction "@$s9Bluetooth6UInt24VyACs6UInt32VcfC".
[16](https://github.com/PureSwift/Bluetooth/actions/runs/3458951709/jobs/5777868385#step:6:17)
 for 'init(_:)' (at /__w/Bluetooth/Bluetooth/Sources/Bluetooth/UInt24.swift:135:5)

@finagolfin
Copy link
Member

OK, that's pretty much the same error I was seeing when building the 5.6 release stdlib natively for linux armv7 earlier in the year, futurejones/ci-swiftlang#12. I'll check and see if I can reproduce on Android armv7.

@colemancda
Copy link
Contributor Author

Would enabling the new Swift Driver (written in Swift) help this issue?

@colemancda
Copy link
Contributor Author

It seems this specific code has been mostly migrated to Swift on trunk ed54253

@eeckstein

@finagolfin
Copy link
Member

Would enabling the new Swift Driver (written in Swift) help this issue?

How would you build the new Swift Driver in the first place, since it requires a working Swift toolchain, cross-compile it too? I suppose that's worth a shot if you think the problem is in the legacy C++ Driver in the Swift compiler.

@colemancda
Copy link
Contributor Author

I'm cross compiling everything, but it seems the passes are still in C++ on 5.7.1 release.

@finagolfin
Copy link
Member

I cross-compile swift-driver for Android now, so there is some support for it in the build scripts, which you'd just have to tweak similarly to what you did to sourcekit-lsp above to get that cross-compiling too.

I'm skeptical that any C++ issue in the C++ driver would stay isolated there though, you'd probably just see other C++ portions of the Swift compiler then fail.

@colemancda
Copy link
Contributor Author

I will try to build natively for i386 to see if the 32-bit issues are reproducible there.

@colemancda
Copy link
Contributor Author

coleman@ctl-j4:~/Developer/Bluetooth$ swift test --sanitize=address
warning: 'bluetooth': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    /home/coleman/Developer/Bluetooth/Sources/Bluetooth/Resources/CompanyIdentifiers.csv

Building for debugging...
<unknown>:0: error: unsupported option '-sanitize=address' for target 'armv7-unknown-linux-gnueabihf'error: fatalError

Can't build with sanitizer. @buttaface Have you tried that on Android?

@finagolfin
Copy link
Member

Yes, the sanitizer tests are run as part of the compiler validation suite on Android AArch64. There was some issue several months ago where a handful of them started failing with this error, but I didn't look into it.

@finagolfin
Copy link
Member

@colemancda, still failing with Swift 6.0? Please close if not.

@colemancda
Copy link
Contributor Author

Gonna have to test again, will try to get to this next week. I've been cross compiling from 5.8-6.0.3 so I haven't encountered this recently.

@xtremekforever
Copy link
Contributor

xtremekforever commented Jan 25, 2025

+1, it would be good to know* if this is still failing. I'm working on the ability to just cross compile from an x86_64 or aarch64 host, but it would be good if the stuff can also build on an armhf host directly.

@xtremekforever
Copy link
Contributor

LOL I tried to run this on my Pi 2B+ and after a day and a half of it struggling to compile LLVM it finally gave up. @colemancda any luck on your end? My Pi only has 1GB of RAM so it couldn't do it... :'(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
armv7 Architecture: ARMv7 bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. build error Errors when building the toolchain, not regular Swift code Linux Platform: Linux
Projects
None yet
Development

No branches or pull requests

4 participants