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

Try swift #50

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

Try swift #50

wants to merge 15 commits into from

Conversation

commjoen
Copy link
Collaborator

@commjoen commjoen commented Feb 24, 2024

What kind of changes does this PR include?

  • Fixes or refactors
  • A new challenge
  • Additional documentation
  • Something else

Description

This builds out a Swift version of the wrongsecrets binaries.

Relations

References

Checklist:

  • All the contributions made are solely the work of me and my co-authors
  • I tested the changes in this PR (if applicable)
  • I added unit tests to ensure my change works (when change in Java or on front-end code)
  • Quickbuild.sh is extended to compile the binary for all target environnments
  • Github actions are implemented to publish the new challenge
  • A spoil command is implemented to return the actual answer
  • The correct and incorrect answer strings are compliant with Contributing.md.
  • The PR passes pre-commit hooks and automated tests

@commjoen
Copy link
Collaborator Author

commjoen commented Feb 26, 2024

We are waiting on swiftlang/swift#62245 as we will need Alpine support for our webtop and need freedom for our java base container to be moveable to alpine again.

@commjoen
Copy link
Collaborator Author

Track swiftlang/swift#47209 :)

@commjoen
Copy link
Collaborator Author

commjoen commented Feb 27, 2024

Chatgpt sais (TLDR: tested does not work...):
To make Swift run on musl libc instead of glibc, you would typically need to cross-compile Swift with musl support. Here's a general approach to do this:

  1. Install musl-libc: First, you need to ensure that musl-libc is installed on your system. If it's not already installed, you can usually find it in your package manager. For example, on Alpine Linux, you can install musl-dev package.

  2. Obtain the Swift source code: Clone the Swift source code from the official repository:

    git clone https://github.com/apple/swift.git
    
  3. Cross-compile Swift with musl support: You'll need to configure Swift's build system to use musl. This typically involves setting up the appropriate flags to point to musl headers and libraries. You can do this by modifying the build script or using cmake directly. Here's a rough outline of how you might do it:

    cd swift
    mkdir build-musl && cd build-musl
    ../configure --target=x86_64-unknown-linux-musl --build=arm-linux-androideabi --enable-optimized --disable-debuginfo --enable-assertions --sysroot=/path/to/musl/sysroot
    make -j8
    

    Replace /path/to/musl/sysroot with the path to your musl sysroot directory. You may need to adjust other flags depending on your system configuration.

  4. Test your musl-enabled Swift build: Once the build process completes successfully, you can test your musl-enabled Swift build by running Swift REPL or compiling and running a simple Swift program.

Keep in mind that cross-compiling software can be complex and may require tweaking depending on your specific setup and requirements. You may encounter issues with dependencies, compiler flags, or compatibility issues between Swift and musl. Be prepared to do some troubleshooting and experimentation to get everything working correctly.

@commjoen
Copy link
Collaborator Author

commjoen commented Feb 28, 2024

Static linking also does not work as we need Foundation. (swiftc -emit-executable -static-executable )

@commjoen
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant