-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Debian packaging support #60690
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
Comments
That file is under the same University of Illinois Open Source License as a lot of LLVM code. In addition, it requires that disclaimer from Unicode, Inc. in the source, not sure why a simple disclaimer is such a problem. Since that file is compiled as part of the LLVM support library
Surely Debian allows exceptions for developer tools like this that need those symbols to work? |
That was a great idea. The llvm-toolchain-14 package has 840 lint errors including this one: I am able to see what they put in their copyright file and will do the same thing. The lint error will just have to be overridden. I see a lot of familiar lint errors in that llvm package so maybe this won't be as big of an issue as I had thought.
I'm sure they do. I was just complaining how this turns into a three step process of disabling the stripping, disabling the lint errors that result, then probably having to explain to a Debian Developer why stripping was disabled. Once I have the low hanging lint errors cleaned up I'll start working on getting the remaining errors reviewed by a Debian Developer to see if they have any concerns that I need to address. |
Here is something else that would help me. Anything that lintian flags as an error is considered to be either a bug in the lint tool or a Debian policy violation. That said, it seems like there is some understanding that it isn't always that simple and overrides of rules are allowed. For the following lintian errors it would be very helpful to know if the error is something I should be able to fix, or is expected. And if expected, what is the reason why. Any explanation that I can add to the comments of the lintian overrides will help to get approval to add the package to Debian. Most errors have multiple failures, but only the first is shown for brevity.
This should be pretty easy for me to fix if this is just an artifact of packaging and not a responsibility of the swift build scripts.
These don't need to be executable do they? I'm not even sure just how they are getting +x.
There are many of this kind. I'm not sure what the issue is as they don't go into the package. Maybe there is a way to clean them up just prior to running lintian?
This is just a warning, but it makes me wonder if I built Swift incorrectly? Maybe it doesn't matter as this is pertaining to the debug symbol package (swiftlang-dbgsym_5.6.2-1_amd64.deb) and I don't think that would be getting added.
If anyone can help make sense of any of these lintian issues that would be most helpful. |
|
I looked up Debian's llvm-toolkit-14 package and wouldn't you know it, they have these same lintian errors and many of the others that I am seeing. If they can have them in llvm then swift should be allowed them as well. The lint tool looks at both the completed package as well as the source, so it seems to pick up all sorts of files that shouldn't matter.
I'm going to look into this some more, but maybe it isn't an issue. Based on the Debian wiki this forces the use of the custom Swift libraries, which I presume is better than picking up the system's libraries for llvm and others. Again, the Debian llvm package has these errors as well so I will contact the maintainer to find out what I can.
For now I'm going to let the Debian build scripts copy over the file and see if that resolves things.
Well, wouldn't you know it. Debian's libicu-dev package has the exact same error on libicudata.a. So I guess nothing to worry about there.
I was able to get those fixed by manually running chmod at the appropriate place in the Debian packaging flow. There is a tool that is supposed to fix this automatically for me so maybe it has a bug. I will have to look into that. At no point in the build process do I see the swift tools setting these files to anything but 0644 and they don't become 0755 until they are copied out into the final directory structure so I'm not sure yet who is doing it.
Yah, probably not an issue. I've just realized that the person that originally wanted to package Swift for Debian back in 2015 was and is a Debian Developer with the LLVM packaging team. If I can pique his interest to sponsor/mentor this package then he already has half of the answers and might even jump at the opportunity to get involved with it again. Crossing my fingers! |
I'm at the point of trying to get a Debian Developer to sponsor my package and clean up any policy violations. The violation that was discovered first is that there is an existing Debian packaged named "python3-swiftclient" and they supply a binary named "swift". Since their binary does something completely different I am not allowed to have a binary named "swift" no matter how unlikely it is for someone to want to use the swift that is designed for server object storage and also compile Swift programs on that same server. I could use the "conflict" mechanism to prevent my package and theirs from being installed at the same time, but policy does not allow that unless the binaries provide the same functionality. The recommended action is to contact the debian-devel mailing list to start a discussion of who has to change their name, or if both have to change their name. At the same time I could ask for an exception to the "conflict" mechanism rule. I guess my main question here is that since "swift" and "swiftc" are both just symbolic links to "swift-frontend" could I drop "swift" from my package and thus require Debian users to always call swiftc instead? Would that break anything other than reams of documentation? |
No, I doubt there's even that much doc on it. |
I don't know yet if this will be allowed by the Debian policy, but what I have done is create a set of scripts such that during the installation process if /usr/bin/swift does not exist the user is presented with a prompt asking if they wish to add it or not. If an actual binary file is located at /usr/bin/swift instead of a symbolic link then a message is printed out warning that "swift" already exists and it cannot be used to call the Swift REPL or compiler/interpreter. |
I've been copying /usr/bin/ls to /usr/bin/swift to test the Debian package install in the case where the "swift" package is installed. If I forget to remove this copy before building Swift then it tries to build newswiftdriver with /usr/bin/swift and fails with a less than helpful message. I'm not sure what all I can do on my end to address this (and may not need to do anything), but I'm wondering if Swift can do a sanity check on /usr/bin/swift before trying to build with it. At a minimum it could verify that it is indeed Swift and is past some minimum version since we know Swift 5.5.1 won't work. |
Are you sure the compiler build even uses |
I tried to reproduce this error on a Swift 5.5.1 build, but was unable to. Here is the log file from trying to build Swift 5.6.2 when Swift is not installed but /usr/bin/swift is some other binary than Swift (copied from /usr/bin/ls in this case):
I'm not likely to be doing any debug or pull requests on this any time soon as I'm focused on packaging. |
I had a similar issue with Swift being installed while packaging, but that was a mistake on my part (testing one version while building another) and the Fedora builders[1] won't have Swift installed by default. [1] Dunno how Debian works, but all packages in the Fedora/RHEL environment are built from source on Fedora-controlled hardware, essentially in a special spun-up container; if I don't include it in the |
Yes, it is the same with Debian. I should be using chroot and a clean build environment each time, but I'm not there yet. There is pretty much no chance that the official Debian package would ever get built with that other "swift" package installed. I have rsync in my build dependencies as well, not because I discovered that on my own, but from benefiting from your work. :-) I've still got some things to sort out, but I'm going to ask if what I have now is good enough to upload to Debian as a starting point. |
out of curiosity, and because I don't have a Debian box handy, what is the other swift program? In Fedora's case there is another swift, but it's part of the OpenStack Object Storage API Python library, so the chance of a conflict with Swift® is effectively nil. |
On Debian/Ubuntu/Pop_OS there is another package "swift" but it doesn't actually provide the binary /usr/bin/swift, that is provided by the related python-swiftclient and they are indeed part of the OpenStack Object Storage API Python library.
I'd prefer to have swiftlang refuse to install if python3-swiftclient is installed, but Debian policy prohibits two packages from providing the same binary unless they are are the same program having different implementations. I could ask for an exception to this policy, but I think prompting to make the link works too. |
Not sure if I got the reviewer on a good day, but I basically said that there is practically zero chance of conflict, given the usage domains were so wildly different; a system using OpenStack Storage is unlikely to also be a developer's machine wanting to use a cool programming language. |
It looks like it's reporting correctly that there's no swiftc, though the error is a bit weird. It has nothing to do with the fake swift binary you added. |
And yet I can repeatedly turn this error on and off by copying a binary to /usr/bin/swift or deleting it. |
Good to know. I've asked my package sponsor how best to handle this and mentioned this as being what Fedora has done. I think the only issue would be not having separate runtime libraries and needing to install swiftlang to get them. Have you done any work on exploring separating out the runtime libraries into their own package? |
Ah, you're right, found it. The current build checks for both |
@tachoknight my Debian sponsor has asked me to move from the Swift provided clang, llvm, cmake, and icu packages to those that come with Debian. I know that lldb is customized by Swift as mentioned in your blog post, but what of these others? I'm assuming that icu and cmake would be fine as long as Swift doesn't depend on a specific version's features. Do you know and/or do you have a blog post about that sort of issues that I can point him to? He is one of the Debian LLVM package maintainers so he is very experienced in this area. Of course anyone else that knows is welcome to chime in too. |
This was my experience as well. The Swift-provided version of LLVM/LLDB is custom for Swift; the standard LLVM/LLDB you might install on any Debian or Fedora box knows nothing about Swift and it simply won't work. The solution I use in Fedora is to hide everything in Two things I can remember too: When I was originally getting it working with Fedora, I discovered that a lot of of the code assumes executables are in the same directory, or if dynamically loading a library, it will explicitly say something like |
Thanks @tachoknight, I have forwarded your reply to my sponsor in the hopes that we will agree to keeping Swift together until upstream makes it possible for us to more easily split it apart. |
As for CMake and ICU, the Swift build just uses the upstream source for each of those, so no problem with not building those from source and using the prebuilt Debian packages instead, provided they're not really old. The only issue is that if you use the system ICU, you may have to bump the Foundation build everytime the system ICU is updated, to make sure it's linked against the latest version, whereas you don't need to do that if you build another libicu for Swift and stash it separately with the Swift-forked lldb and so on. |
Not Swift, I believe they just want to slowly upstream all Swift changes from their forked LLVM/clang/lldb to the upstream LLVM repo and get rid of those LLVM forks one day, but I'm guessing that's probably years away. |
Ah, that's right, I was remembering it incorrectly. |
Thank you all for the information and help. My sponsor would like me to move to as many Debian packages as possible so here is our plan:
|
Out of curiosity, what does it mean to switch to the Debian llvm and clang? |
I'm hoping that will be open for negotiation. The desire is to not be packaging yet another fork of llvm/lldb/clang and having to deal with its bugs, but how do I make use of a tool chain that doesn't support my language? Start submitting all of Swift's changes as pull requests to Debian's LLVM packages? At that point it seems like you're still having to maintain a fork, but now those bugs impact far more Debian users than just the swiflang users. In any case, I must at least give it the old college try. |
@melizasw Many thanks for your sharing about this, I will try it on my side. BTW, do you need one real riscv64 hardware to debug something on here? if so, I can offer you with access remote with ssh. |
@melizasw It moved forward a lot with your patch. now it failed with the below: public/CMakeFiles/swiftDemangling-linux-riscv64.dir/__/__/lib/Demangling/Errors.cpp.o.d -o stdlib/public/CMakeFiles/swiftDemangling-linux
-riscv64.dir/__/__/lib/Demangling/Errors.cpp.o -c /<<PKGBUILDDIR>>/swift/lib/Demangling/Errors.cpp
In file included from /<<PKGBUILDDIR>>/swift/lib/Demangling/Errors.cpp:19:
In file included from /<<PKGBUILDDIR>>/swift/include/swift/Demangling/Errors.h:24:
In file included from /<<PKGBUILDDIR>>/build/buildbot_linux/llvm-linux-riscv64/lib/clang/13.0.0/include/inttypes.h:21:
In file included from /usr/include/inttypes.h:25:
In file included from /usr/include/features.h:402:
/usr/include/features-time64.h:20:10: fatal error: 'bits/wordsize.h' file not found
#include <bits/wordsize.h>
^~~~~~~~~~~~~~~~~
1 error generated.
[48/1463][ 3%][2.057s] Copying Target.h to /<<PKGBUILDDIR>>/build/buildbot_linux/swift-linux-riscv64/./lib/swift/shims
[49/1463][ 3%][2.058s] Copying UnicodeData.h to /<<PKGBUILDDIR>>/build/buildbot_linux/swift-linux-riscv64/./lib/swift/shims
[50/1463][ 3%][2.059s] Copying ThreadLocalStorage.h to /<<PKGBUILDDIR>>/build/buildbot_linux/swift-linux-riscv64/./lib/swift/shims
[51/1463][ 3%][2.170s] Copying module.modulemap to /<<PKGBUILDDIR>>/build/buildbot_linux/swift-linux-riscv64/./lib/swift/shims
... It seems it has finished the first stage of building. I am looking at link you gave me above. |
Yes, I am getting the same error now. It can't seem to locate /usr/include/riscv64-linux-gnu/bits/wordsize.h even though it has no problem doing so on x86_64 and arm64. I will try to dig into this tonight after work. This is the same error that I got on 5.7.3 that stopped me and I did not get past. My best guess is an issue configuring include paths in the CMake files. |
I added this to my build script and it works now:
|
@melizasw It turned out to be a little bit more difficult than what I initially wrote. Here's the patch file I addd to make it work reliably. Hopefully that helps. :) |
Yah, I ended up using this patch:
The issue now is that 5.8.1 builds fine on amd64, but fail with a stack dump on arm64 with Clang 18 and 19. I'm a little stumped, but haven't spent a lot of time on it yet. Might be related to #70345
|
Confirmed that 5.8.1 build failures on Debian Sid with default Clang package (Clang 19) on Arm64 are fixed with the patch provided with bug report #70345
|
I have 5.9.2 building fine on x86_64, but on aarch64:
Sigh ETA: Self-induced with a patch that hard coded that path. |
On to the next issue with packaging 5.9.2. It builds on x86_64 but not aarch64. I've traced it down to an error parsing json by swiftpm/Utilities/bootstrapping because switfc outputs some non-json on aarch64 that trips up the json parser. x86_64:
aarch64:
Swiftc 5.8.1 on aarch64 does not print this message. Does anyone have an idea on this one? |
5.9.2 is now building on Arm after modifying swift/include/swift/Runtime/Config.h to match Debian's page sizes.
|
Just a happy little update. With version 5.8.1 I was finally able to figure out why my builds always failed on Ubuntu. It turns out to have been a "known issue" for the Ubuntu folks where they include some GCC LTO flags by default, knowing that it will break a Clang build. So now Swift 5.8.1 is in Ubuntu Plucky and should be available to all Ubuntu derivatives. Swift 5.9.2 is ready now and should be on its way into the repositories soon. |
Swift 5.9.2 made it into Debian unstable and out to Ubuntu Plucky. It should be replaced soon by 5.10.1 which leaves me with the exciting work of getting 6.0.3 ready for Debian. The build of 6.0.3 goes quite far, but fails when building libFoundationEssentials.so from the new swift-foundation. This is the error: It is plainly obvious that these are linker arguments that one would pass to Clang, but instead they are being passed to swiftc:
I've not yet figured out what is injecting these arguments, can anyone help me locate this? Also, until now the Swift build has always chosen GNU ld for linking, but with 6.0.3 it now seemingly randomly switches between GNU ld and GNU gold. Should I add GNU gold as a build depends (it is not a build depends now) or stick with just GNU ld? |
This looks like something that might be coming in from CMake. I don't know whether it's a Debian patch to CMake, something that Foundation is doing that's only triggering on Debian, or something else. Some places to look are in the build directory,
This is likely because we leave it up to the clang-linker to decide which one to use by default and it might be picking up different clang-linkers through the build because build-script is not terribly water-tight and changes things through the build. You can specify the linker that the toolchain will use by default by passing Lines 925 to 927 in 57657c6
That said, there was some work done on the BFD linker that fixes the relocation bug, so new versions of the GNU BFD linker should work now. |
Hey @melizasw, been awhile since I responded to this thread, as there was a problem with my github account a couple years ago, which appears to have removed this issue from my notifications back then.
What version of CMake are you using? I reported a regression in CMake 3.30 to @etcwilde months ago- maybe he didn't see it or forgot- where it started passing |
Debian has been on CMake 3.31 since late November. Your suggested fix did the trick, thanks for that. So now I'm on to the next error. It seems to be a failed assertion when calling computeHostNumPhysicalCores() within llbuild/lib/llvm/Support/Host.cpp. Since this is a linux build this function is getting the core count from /proc/cpuinfo and putting it into a SmallVector which I assume uses a BitVector. FAILED: lib/llvm/Support/CMakeFiles/llvmSupport.dir/Host.cpp.o The file llbuild/lib/llvm/Support/Host.cpp appears to have not been touched in the last 6 years so there must have been a change elsewhere that has triggered this. |
Can you paste the whole error? This seems like an assertion in the freshly-built Swift-forked clang itself, not anything in llbuild. |
Yes, please let me know if you want me to provide more of the earlier part of the log file or the files in /tmp that it references.
|
Hmm, somebody reported the same error with the Swift-forked clang 10 months ago, swiftlang/llvm-project#8741, which they say led to cherry-picking swiftlang/llvm-project@91d7ca904 into the Swift fork. I see that it only made it into the upcoming Swift 6.1 though, not Swift 6.0, so try applying that patch to your 6.0 build and see if it fixes this issue. I'm not sure why the official Swift CI doesn't hit this also, may be related to it still building the Swift-forked clang in the current Swift 6 branches with the older clang in Swift 5.9, swiftlang/swift-docker#368, or some even older system clang? Maybe something in the host clang triggers this bug in the Swift-forked clang somehow. 🤷♂ |
Yes, that did the trick. Now I'm on to the next error. Apparently I didn't grab swift-testing when I was assembling my source tarball. I'll have to fix that tomorrow. I don't know how you managed to find that bug report and fix. I tried to search for similar error messages and wasn't getting anywhere. The help is much appreciated. Running into bugs like this when building for Debian seems to be par for the course. Not sure why. |
Once I saw it was a clang error, I ran this search using the analysis pass from your error in that repo for the Swift-forked LLVM and that single issue came up. 😃
It's not just Debian, the Fedora build and others have reported similar issues, as the Swift toolchain build doesn't seem very robust on these non-Darwin platforms. Perhaps that's because the uptake outside macOS is still low- compare it to Rust- which will only change once more people are building it in more settings. |
Ok, I guess I was going after the wrong string in the error message and was blaming llbuild and not llvm so I was searching the wrong bug reports. I'm now on what I hope will be the final build error - my old friend the architecture triple. You see, Swift takes the approach that everything Linux is {arch}-unknown-linux-gnu. Debian agrees with this on aarch64, but on x86_64 the vendor string is "pc" instead of "unknown". The new error appears to be caused by utils/swift_build_support/swift_build_support/products/product.py
I'll find out in a few hours if my patch to set the vendor string works or not. I've also kicked off a build on my Pi5 as it shouldn't be hampered by this bug. |
Yes, that fixed that issue, but it wasn't the last one. At least I have a good idea where to look.
|
Yep, thanks again. It was late at night and I had to give up even though I knew it wouldn't be too hard to find. Kicked off a new build, but I have to wait till after work tonight to see if it finishes or finds something new to error out on. |
That was indeed the last build error and I now have complete builds on x86_64 and aarch64. There are some packaging issues to work through and some additional testing to do, but that should all be fairly straight forward. Thank you all for the help. |
I'm now working on building Swift 6.1 using 6.0.3 and everything has been pretty smooth except for WASM. As far as I can tell WASM was not built as part of 6.0.3 even though it was present in the source code package. The error is that when building wasmstdlib it errors out when trying to compile swift/lib/Demangling/Errors.cpp
This is because
I also tried to find where Something else of note, when building 6.0.3 the test COMPILER_RT_HAS_FCF_PROTECTION_FLAG is ran once on the system clang and once on the Swift provided clang and both report Any ideas at what is going on with wasm? Also, for 6.0.3 I was able to use the Debian provided wasi-libc, but with 6.1 it complains if I don't provide it the source code to compile and I don't see an easy way to turn it off in |
I disabled |
I've figured out to disable the wasi-libc compile I need to comment out At any rate, I've gotten the wasi-libc build disabled and now just need to figure out the correct place to add the paths to the system libs(/usr/lib/wasm32-wasi/) and includes (/usr/include/wasm32-wasi/).
Does anyone know where that happens? This and the -fcf-protection error are hopefully the only issues I need to resolve to have wasm support. |
It turns out that Debian dpkg is who is adding the troublesome -fcf-Protection flags and I was able to turn them off by adding the following to debian/rules:
I've now completed a build of 6.1 with the exception of wasi-libc being that which Swift expects to be bundled with it instead of the system library. I'm still open to suggestions on that if anyone has any ideas. |
@buttaface suggested that I start a new issue here to discuss problems that arise while I am packaging Swift for Debian. I have found the Fedora packaging that @tachoknight has done to be very helpful in this effort. A related work that I just learned of from @etcwilde is work on packaging for Ubuntu in the swift-installer-scripts repo.
The challenges are mainly getting Swift to build into a .deb package using the
debuild
tool and getting the packing into compliance with Debian policy. It has a very powerful linting tool that checks for many common errors and issues and most Debian Developers won't sign off on a package that isn't lint clean or reasonably close to it.Here is the biggest issue that I know of right now. The file
ConvertUTF.cpp
uses a non-free license and is located in three places:Debian suggests replacing these files with libicu, which is already a part of Swift. But there are other alternatives out there as well such as utfcpp.
I am not a software engineer by trade so it is unlikely that I could make this replacement on my own without making a mess of things.
Another linting error that I can probably resolve post-bulid on my own is that many libraries have executable permissions. For example:
E: swiftlang: shared-library-is-executable 0755 [usr/libexec/swift/lib/clang/10.0.0/lib/linux/libclang_rt.dyndd-x86_64.so]
And another example of how challenging this packaging can be, I can't strip the binaries or REPL won't work and when I disable the binary stripping the lint tool then complains that the binaries have not been stripped. sigh
The text was updated successfully, but these errors were encountered: