Compile Error - Arch Linux

I know that Arch Linux is not a "Supported Target Platforms" so I guess
this may be off topic.

However, I'm trying to make an PKGBUILD script so that Swift can be
installed from the AUR (and perhaps eventually from the main
repositories). See: GitHub - RLovelett/swift-aur: Temporary location for my Swift PKGBUILD. I'll put it on AUR once I get it working right.

For the most part everything is going swimmingly until it goes to link
the shared library libswiftCore.so. So as not to clutter up this message
with the full log (see attached allout.txt). The germane part is that it
is failing to link the references from `pthread_rwlock_rdlock`,
`pthread_rwlock_unlock`, `pthread_rwlock_wrlock`, `dlopen`, `dlsym` and
`dlclose`. As far as I know they all come from pthreads and dl (e.g.,
`-lpthread` and `-ldl`) which can clearly be seen in the failed command
as having been sent to clang++.

I guess I should also say the command I am using to build is
`swift/utils/build-script -R`; though if you want to see all the
commands checkout the Github URL above.

My guess is something is going wrong during the build script but I'm not
really sure where and how to start debugging it in isolation.
Suggestions are welcome.

allout.txt (9.52 KB)

···

--
Ryan Lovelett

I realized that the first log that I sent didn't have the full log. It
excluded the parts that succeeded and only included the failure. I reset
the build and completely re-ran the whole thing. It should now include
the configuration stuff.

allout.txt (285 KB)

I think the issue is that '-lpthread -ldl' are being specified too
early on the link line, before the object files. Could you try
editing the link command to put '-lpthread -ldl' at the end and
retrying it in the build directory after the failure?

For a package build, I would also recommend running the build script
in preset mode and using the 'buildbot_linux_1404' preset:

$ ./swift/utils/build-script --preset=buildbot_linux_1404
installable_package=/tmp/swift.tar.gz
install_destdir=/tmp/swift-install

This will build the package the same way as the swift.org packages.

Dmitri

···

On Fri, Dec 4, 2015 at 6:08 AM, Ryan Lovelett <swift-dev@ryan.lovelett.me> wrote:

I know that Arch Linux is not a "Supported Target Platforms" so I guess
this may be off topic.

However, I'm trying to make an PKGBUILD script so that Swift can be
installed from the AUR (and perhaps eventually from the main
repositories). See: GitHub - RLovelett/swift-aur: Temporary location for my Swift PKGBUILD. I'll put it on AUR once I get it working right.

For the most part everything is going swimmingly until it goes to link
the shared library libswiftCore.so. So as not to clutter up this message
with the full log (see attached allout.txt). The germane part is that it
is failing to link the references from `pthread_rwlock_rdlock`,
`pthread_rwlock_unlock`, `pthread_rwlock_wrlock`, `dlopen`, `dlsym` and
`dlclose`. As far as I know they all come from pthreads and dl (e.g.,
`-lpthread` and `-ldl`) which can clearly be seen in the failed command
as having been sent to clang++.

I guess I should also say the command I am using to build is
`swift/utils/build-script -R`; though if you want to see all the
commands checkout the Github URL above.

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/

Dmitri,

Thanks for the extra set of eyes. I have confirmed that moving
'-lpthread -ldl' to either the beginning or end will allow that step to
succeed. The part that I'm stuck on is where that linker argument comes
from in the first place and how to reorder them. Do you happen to have
any insight on that?

For the 'final' package build script I plan to make my own preset for
arch linux that is based on 'mixin_linux_installation'. This is what
'buildbot_linux_1404' and 'buildbot_linux_1510' are based on. I just
want be able to consistently build before I start tweaking parameters.

Again thank you for your suggestions.

···

On Sat, Dec 5, 2015, at 03:31 AM, Dmitri Gribenko wrote:

On Fri, Dec 4, 2015 at 6:08 AM, Ryan Lovelett > <swift-dev@ryan.lovelett.me> wrote:
> I know that Arch Linux is not a "Supported Target Platforms" so I guess
> this may be off topic.
>
> However, I'm trying to make an PKGBUILD script so that Swift can be
> installed from the AUR (and perhaps eventually from the main
> repositories). See: GitHub - RLovelett/swift-aur: Temporary location for my Swift PKGBUILD. I'll put it on AUR once I get it working right.
>
> For the most part everything is going swimmingly until it goes to link
> the shared library libswiftCore.so. So as not to clutter up this message
> with the full log (see attached allout.txt). The germane part is that it
> is failing to link the references from `pthread_rwlock_rdlock`,
> `pthread_rwlock_unlock`, `pthread_rwlock_wrlock`, `dlopen`, `dlsym` and
> `dlclose`. As far as I know they all come from pthreads and dl (e.g.,
> `-lpthread` and `-ldl`) which can clearly be seen in the failed command
> as having been sent to clang++.
>
> I guess I should also say the command I am using to build is
> `swift/utils/build-script -R`; though if you want to see all the
> commands checkout the Github URL above.

I think the issue is that '-lpthread -ldl' are being specified too
early on the link line, before the object files. Could you try
editing the link command to put '-lpthread -ldl' at the end and
retrying it in the build directory after the failure?

For a package build, I would also recommend running the build script
in preset mode and using the 'buildbot_linux_1404' preset:

$ ./swift/utils/build-script --preset=buildbot_linux_1404
installable_package=/tmp/swift.tar.gz
install_destdir=/tmp/swift-install

This will build the package the same way as the swift.org packages.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/

Dmitri,

Thanks for the extra set of eyes. I have confirmed that moving
'-lpthread -ldl' to either the beginning or end will allow that step to
succeed. The part that I'm stuck on is where that linker argument comes
from in the first place and how to reorder them. Do you happen to have
any insight on that?

Ryan,

Highly likely it is this line that adds them:

cmake/modules/AddSwift.cmake: list(APPEND result "-lpthread" "-ldl")

For the 'final' package build script I plan to make my own preset for
arch linux that is based on 'mixin_linux_installation'. This is what
'buildbot_linux_1404' and 'buildbot_linux_1510' are based on. I just
want be able to consistently build before I start tweaking parameters.

Sounds good.

Dmitri

···

On Sat, Dec 5, 2015 at 6:28 AM, Ryan Lovelett <swift-dev@ryan.lovelett.me> wrote:

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/

I've made a pull request, Fix linker not finding pthreads or dl by RLovelett · Pull Request #435 · apple/swift · GitHub, that
attempts to fix this problem. I'm not entirely sure why clang is not
seeing the flags they are clearly in the argument list.

···

On Sat, Dec 5, 2015, at 05:15 PM, Dmitri Gribenko wrote:

On Sat, Dec 5, 2015 at 6:28 AM, Ryan Lovelett > <swift-dev@ryan.lovelett.me> wrote:
> Dmitri,
>
> Thanks for the extra set of eyes. I have confirmed that moving
> '-lpthread -ldl' to either the beginning or end will allow that step to
> succeed. The part that I'm stuck on is where that linker argument comes
> from in the first place and how to reorder them. Do you happen to have
> any insight on that?

Ryan,

Highly likely it is this line that adds them:

cmake/modules/AddSwift.cmake: list(APPEND result "-lpthread" "-ldl")

> For the 'final' package build script I plan to make my own preset for
> arch linux that is based on 'mixin_linux_installation'. This is what
> 'buildbot_linux_1404' and 'buildbot_linux_1510' are based on. I just
> want be able to consistently build before I start tweaking parameters.

Sounds good.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/