Skip to content

Update FreeBSD packaging script #443

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions platforms/FreeBSD/makePackage
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ cd "$CURRENT_DIRECTORY"
SWIFT_VERSION="$("$SWIFT_TOOLCHAIN_HOME/bin/swift" --version | grep -Eo 'version [0-9.]+' | sed 's/version //')"
echo "Swift version being packaged is $SWIFT_VERSION"

# Get the currently installed version for all of the packages that we need.
# This script assumes that it was run on the build machine and therefore
# that the packages on this machine correspond to those Swift was built
# against.
get_package_version()
{
echo "$(pkg info "$1" | grep Version | sed 's/Version.*: //')"
}

LIBUUID_PKG_VERSION=$(get_package_version libuuid)
LIBFFI_PKG_VERSION=$(get_package_version libffi)
LIBXML2_PKG_VERSION=$(get_package_version libxml2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I am weary about. Can we pin this to the exact version? I learnt that this library is not ABI stable and does not follow standard versioning practices. We are pinned to the exact version of libxml2 on Windows as there were ABI changes that break FoundationXML.

Copy link
Contributor Author

@CodingCarpincho CodingCarpincho Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've encountered this problem as well. I'd like Swift on FreeBSD to do a static link against this dependency, but @etcwilde would need to chime in as I don't think we can do static linking of the compiler.

Edit: It looks like the FreeBSD package repositories provide a libxml2.a alongside the dynamic libraries when you install the LibXML2 package. Perhaps it would be worth considering linking statically to that dependency on FreeBSD without statically linking the whole compiler.

MPDECIMAL_PKG_VERSION=$(get_package_version mpdecimal)
PYTHON_PKG_VERSION=$(get_package_version python311)
READLINE_PKG_VERSION=$(get_package_version readline)
SQLITE3_PKG_VERSION=$(get_package_version sqlite3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need SQLite? I thought we used swift-toolchain-sqlite now and thus do not need the system vended SQLite.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the idea for swift-toolchain-sqlite is that it's for systems without a native package management system to provide sqlite... meaning Windows and Android.

So far on Darwin we've been using the system SQLite and on Linux we've still been using the copy provided by the package manager... I expect it would make sense for FreeBSD to do the same as Linux here.


# Create the manifest file. All fields below are required. pkg_create(3)
# will add additional fields as part of generating the package.
echo "Generating manifest..."
Expand All @@ -93,32 +110,32 @@ cat > "$METADATA_STAGING/manifest" <<EOF
"maintainer": "[email protected]",
"www": "https://www.swift.org",
"deps": {
"e2fsprogs-libuuid": {
"version": "1.47.1",
"origin": "misc/e2fsprogs-libuuid"
"libuuid": {
"version": "$LIBUUID_PKG_VERSION",
"origin": "misc/libuuid"
},
"libffi": {
"version": "3.4.6",
"version": "$LIBFFI_PKG_VERSION",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think libffi is needed only because of Python. I think we can just include the direct dependencies so the package manager can take care of the rest

"origin": "devel/libffi"
},
"libxml2": {
"version": "2.11.9",
"version": "$LIBXML2_PKG_VERSION",
"origin": "textproc/libxml2"
},
"mpdecimal": {
"version": "4.0.0",
"version": "$MPDECIMAL_PKG_VERSION",
"origin": "math/mpdecimal",
},
"python311": {
"version": "3.11.11",
"version": "$PYTHON_PKG_VERSION",
"origin": "lang/python311"
},
"readline": {
"version": "8.2.13_2",
"version": "$READLINE_PKG_VERSION",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably from Python too

"origin": "devel/readline"
},
"sqlite3": {
"version": "3.46.1_1,1",
"version": "$SQLITE3_PKG_VERSION",
"origin": "databases/sqlite3"
}
}
Expand Down