Update 3
Okay, I've created a minimally reproducible SPM project. All it is is a default SPM project with the Swift-JWT from Kitura dependency added.
After cloning of the project, you can run this Docker command from the root of the project directory to see the error:
docker run \
--rm \
--volume "$(pwd)/:/src" \
--workdir "/src/" \
swift:5.3.1-amazonlinux2 \
swift build --product MissingPCFile -c release -Xswiftc -static-stdlib
If anyone has any insight to lend on the matter it would be greatly appreciated!
Update 2
I found the problem dependency. It is Swift-JWT from Kitura. Project compiles fine before the commit that incorporates that dependency, but following it, experiences the couldn't find pc file
error.
Strangely, whenever I run the docker command to compile the project for AWS on any commit from this one on, and then do a git status
my Package.resolved
file has been altered. The alteration is the addition of the OpenSSL package:
"version": "1.9.200"
}
},
{
+ "package": "OpenSSL",
+ "repositoryURL": "https://github.com/Kitura/OpenSSL.git",
+ "state": {
+ "branch": null,
+ "revision": "80b04f33b086fc90e28d9ae159d43705fb348e16",
+ "version": "2.2.200"
+ }
+ },
{
"package": "postgres-kit",
"repositoryURL": "https://github.com/vapor/postgres-kit.git",
However, this appears to be something different than the system OpenSSL; which I imagine is why the installations of openssl-devel
and openssl
didn't resolve the issue — as the error is not referring to the pc
file of the system's OpenSSL, but perhaps to that of Kitura's OpenSSL.
Update 1
This appears to be an issue with the pkg-config
utility in the Amazon Linux 2 Docker container. I've checked the openssl-devel
installation in the container and openssl.pc
exists inside /usr/lib64/pkgconfig
. When I run pkg-config --variable pc_path pkg-config
to see where the utility is checking for these pc files, the following is output:
/usr/lib64/pkgconfig:/usr/share/pkgconfig
The first item being the very directory where openssl.pc
exists. I also read talk of a $PKG_CONFIG_PATH
environment variable, so I figured it may be possible that this value is being used instead. Low and behold after echoing the value it was completely empty. So I set its value to that which was output above, but it didn't change anything.
Original
I posted the following question on StackOverflow first. But it hasn't gotten a response, and being that it appears to be an issue with the Swift Package Manager on Linux, I decided to come and see if anyone has any light to shed on the matter here at Swift HQ. For convenience, I've copied it below.
I basically followed this tutorial initially in order to create a basic AWS Swift Lambda. As a part of it you are meant to package the Swift project in an Amazon Linux 2 Docker image. I'm using the below command to do so:
docker run \
--rm \
--volume "$(pwd)/:/src" \
--workdir "/src/" \
swift:5.3.1-amazonlinux2 \
swift build --product API -c release -Xswiftc -static-stdlib
And initially, it always worked. But I've been working on a particular component of the project for a while that has required adding some new dependencies. Ready to test it I reissued the above command but this time was met with this as the first line of the output:
'OpenSSL' openssl.pc: warning: couldn't find pc file
Then the command proceeds to compile different package components. It gets to [14/1013] which is CryptorRSA
of the BlueRSA library and outputs this error:
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "shim.h"
^
/src/.build/checkouts/OpenSSL/Sources/OpenSSL/shim.h:20:10: error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
^
/src/.build/checkouts/BlueRSA/Sources/CryptorRSA/CryptorRSA.swift:25:12: error: could not build C module 'OpenSSL'
import OpenSSL
^
It then proceeds to compile 5 more items ([15-19/1013]), until terminating, presumably due to the missing "pc" file.
I've tried running yum -y install openssl-devel
on the Docker image, but to no avail. Also, I only have a single Docker image on my machine according to the Docker desktop app, so I'm fairly certain I'm not installing openssl-devel
on some other image; because as far as I can tell there aren't any.
I've tried installing openssl
(without "-devel"), but the problem persists.
How do you resolve this issue?