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

llbuild: 'sqlite3.h' file not found #901

Open
SMillerDev opened this issue Jan 1, 2024 · 5 comments
Open

llbuild: 'sqlite3.h' file not found #901

SMillerDev opened this issue Jan 1, 2024 · 5 comments
Labels

Comments

@SMillerDev
Copy link

Description

When trying to build swift 5.9.2 in Homebrew, the build fails with:

2023-12-24T16:55:37.9717810Z /tmp/swift-20231224-11721-bkt1we/llbuild/lib/Core/SQLiteBuildDB.cpp:28:10: fatal error: 'sqlite3.h' file not found
2023-12-24T16:55:37.9717913Z #include <sqlite3.h>
2023-12-24T16:55:37.9717995Z          ^~~~~~~~~~~
2023-12-24T16:55:37.9718084Z 1 error generated.

Despite sqlite3 being included as a dependency.

Reproduction

See Homebrew/homebrew-core#157113 for the full build

Expected behavior

Completed build

Environment

Swift 5.9.2

Additional information

While this very well might be a Homebrew issue, we could use some help trying to figure out if it is.

@SMillerDev SMillerDev added the bug label Jan 1, 2024
@compnerd
Copy link
Collaborator

compnerd commented Jan 2, 2024

How are you invoking swift build? You should be passing the header search path or ensuring that the systemLibrary dependency is set up with the right paths.

@compnerd compnerd transferred this issue from apple/swift Jan 2, 2024
@Bo98
Copy link

Bo98 commented Feb 4, 2024

How are you invoking swift build?

Via SwiftPM bootstrap rather than llbuild directly.

the systemLibrary dependency

Where is this dependency located? SQLite3 seems to only be passed as a linker flag here:

linkerSettings: [.linkedLibrary("sqlite3")]
and there's already an OpenBSD-specific hack for a similar issue:

swift-llbuild/Package.swift

Lines 279 to 287 in 783aec2

#if os(OpenBSD)
if let target = package.targets.first(where: { $0.name == "llbuildCore"}) {
target.cSettings = [.unsafeFlags(["-I/usr/local/include"])]
target.linkerSettings = [
.linkedLibrary("sqlite3"),
.unsafeFlags(["-L/usr/local/lib"])
]
}
#endif

It should be able to pick up the pkg-config like the CMake part of the build is able to.

@Bo98
Copy link

Bo98 commented Feb 4, 2024

Issue seems to just be #733 again but s/OpenBSD/any other non-usr install/

@Bo98
Copy link

Bo98 commented Feb 21, 2024

Reproduction steps:

$ docker run --rm -it swift:5.9.2
# apt update
# apt install g++ make cmake curl
# cd /root
# curl -LO https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz
# tar xf sqlite-autoconf-3450100.tar.gz
# cd sqlite-autoconf-3450100
# ./configure --prefix=/opt/prefix
# make install
# cd ..
# export PKG_CONFIG_PATH=/opt/prefix/lib/pkgconfig
# pkg-config --cflags sqlite3
-I/opt/prefix/include
# git clone https://github.com/apple/swift-package-manager
# cd swift-package-manager
# git checkout swift-5.9.2-RELEASE
# swift build
/root/swift-package-manager/.build/checkouts/swift-llbuild/lib/Core/SQLiteBuildDB.cpp:28:10: fatal error: 'sqlite3.h' file not found
#include <sqlite3.h>
         ^~~~~~~~~~~
1 error generated.

@finagolfin
Copy link
Contributor

I ran another test in that linked 5.9.2 pull and I think he is right that llbuild should specify the systemLibrary dependency explicitly in Package.swift, or it fails for any non-standard directory where it may be installed, such as when cross-compiling.

I'm guessing he could make this more explicit by trying to build the llbuild package alone with SwiftPM in his example above and that would also fail, as the Swift toolchain build avoids that by building llbuild alone with CMake, obviously since SwiftPM isn't built yet when first building llbuild alone in the toolchain build.

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

No branches or pull requests

4 participants