Error with SwiftGlibs building for arm-linux

Dear colleagues
I have faced with strange behaviour, when I compile some swift source on Ubuntu 14, target=arm-linux-gnueabi, all neccessary modules for arm present, -sysroot and
-isysroot are passed via -Xcc.

<module-includes>:61:10: note: in file included from <module-includes>:61:
#include "/usr/include/x86_64-linux-gnu/sys/wait.h"
         ^
/usr/include/x86_64-linux-gnu/sys/wait.h:148:20: error: unknown type name 'idtype_t'
extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
                   ^
<unknown>:0: error: could not build Objective-C module 'SwiftGlibc'

Arm 32-bit pcm for SwiftShims was build successfully, but SwiftGlibc after it is not. Is it true, that compiler generates include-directive with path, starting from "/usr/include/x86_64-linux-gnu", that is on native host? What arguments I have to point out for swiftc to avoid such situation? But if that is true, and swiftc needs some headers on native host, I will looking for idtype_t definition. What do you think?

You need a different variant of the module map for Glibc that
references the arm triple.

Dmitri

···

On Thu, Mar 24, 2016 at 1:30 PM, Труб Илья <swift-dev@swift.org> wrote:

Dear colleagues
I have faced with strange behaviour, when I compile some swift source on Ubuntu 14, target=arm-linux-gnueabi, all neccessary modules for arm present, -sysroot and
-isysroot are passed via -Xcc.

<module-includes>:61:10: note: in file included from <module-includes>:61:
#include "/usr/include/x86_64-linux-gnu/sys/wait.h"
         ^
/usr/include/x86_64-linux-gnu/sys/wait.h:148:20: error: unknown type name 'idtype_t'
extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
                   ^
<unknown>:0: error: could not build Objective-C module 'SwiftGlibc'

--
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>*/

Thanks for your answer, Dmitry. I will look for examples of module maps in test sources.

···

24.03.2016, 23:56, "Dmitri Gribenko" <gribozavr@gmail.com>:

On Thu, Mar 24, 2016 at 1:30 PM, ���� ���� <swift-dev@swift.org> wrote:

�Dear colleagues
�I have faced with strange behaviour, when I compile some swift source on Ubuntu 14, target=arm-linux-gnueabi, all neccessary modules for arm present, -sysroot and
�-isysroot are passed via -Xcc.

�<module-includes>:61:10: note: in file included from <module-includes>:61:
�#include "/usr/include/x86_64-linux-gnu/sys/wait.h"
����������^
�/usr/include/x86_64-linux-gnu/sys/wait.h:148:20: error: unknown type name 'idtype_t'
�extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
��������������������^
�<unknown>:0: error: could not build Objective-C module 'SwiftGlibc'

You need a different variant of the module map for Glibc that
references the arm triple.

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>*/

You shouldn't need to. If you have built Swift for arm, you should
have the right one produced by the build system.

How did you compile the standard library for arm?

Dmitri

···

On Thu, Mar 24, 2016 at 2:03 PM, Труб Илья <itrub@yandex.ru> wrote:

Thanks for your answer, Dmitry. I will look for examples of module maps in test sources.

--
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 have built all targets for arm (including modules and libraries) within the native arm environment on arm-emulator with chroot.

···

25.03.2016, 00:25, "Dmitri Gribenko" <gribozavr@gmail.com>:

On Thu, Mar 24, 2016 at 2:03 PM, ���� ���� <itrub@yandex.ru> wrote:

�Thanks for your answer, Dmitry. I will look for examples of module maps in test sources.

You shouldn't need to. If you have built Swift for arm, you should
have the right one produced by the build system.

How did you compile the standard library for arm?

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>*/

Then you should have a module map for Glibc in the build products.

Dmitri

···

On Thu, Mar 24, 2016 at 2:32 PM, Труб Илья <itrub@yandex.ru> wrote:

I have built all targets for arm (including modules and libraries) within the native arm environment on arm-emulator with chroot.

25.03.2016, 00:25, "Dmitri Gribenko" <gribozavr@gmail.com>:

On Thu, Mar 24, 2016 at 2:03 PM, Труб Илья <itrub@yandex.ru> wrote:

Thanks for your answer, Dmitry. I will look for examples of module maps in test sources.

You shouldn't need to. If you have built Swift for arm, you should
have the right one produced by the build system.

How did you compile the standard library for arm?

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>*/

--
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>*/

Yes, Dmitry. I found corresponding module.map for arm and placed it into glibs subdirectory of my swiftc's include path. It was found. But, it seems to me, sysroot argument is not applied to paths, written in that module.map or I do not how to correct do that.
I add to swift command-line following option:
-Xcc "-sysroot <msysroot>", but now I get error:

<my swift include path>/glibc/module.map:187:14: error: header '/usr/include/sys/ioctl.h' not found
      header "/usr/include/sys/ioctl.h"
             ^
<unknown>:0: error: could not build Objective-C module 'SwiftGlibc'

I checked, that file <mysysroot>/usr/include/sys/ioctl.h actually exists. Could you hint, what I do wrong?

···

25.03.2016, 01:15, "Dmitri Gribenko" <gribozavr@gmail.com>:

Then you should have a module map for Glibc in the build products.

Dmitri

On Thu, Mar 24, 2016 at 2:32 PM, ���� ���� <itrub@yandex.ru> wrote:

�I have built all targets for arm (including modules and libraries) within the native arm environment on arm-emulator with chroot.

�25.03.2016, 00:25, "Dmitri Gribenko" <gribozavr@gmail.com>:

�On Thu, Mar 24, 2016 at 2:03 PM, ���� ���� <itrub@yandex.ru> wrote:

��Thanks for your answer, Dmitry. I will look for examples of module maps in test sources.

�You shouldn't need to. If you have built Swift for arm, you should
�have the right one produced by the build system.

�How did you compile the standard library for arm?

�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>*/

--
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>*/

It seems to me, the last phenomena is explained by swift compiler bug. Let us look into clang/lib/Lex/ModuleMap.cpp source file, method parseHeaderDecl. We can find, for example, following lines:
if (llvm::sys::path::is_absolute(Header.FileName)) {
    RelativePathName = Header.FileName;
    File = SourceMgr.getFileManager().getFile(RelativePathName);
}
We can see, that sysroot (or isysroot) argument is ignored. What can you say about that?

···

25.03.2016, 12:21, "���� ���� via swift-dev" <swift-dev@swift.org>:

Yes, Dmitry. I found corresponding module.map for arm and placed it into glibs subdirectory of my swiftc's include path. It was found. But, it seems to me, sysroot argument is not applied to paths, written in that module.map or I do not how to correct do that.
I add to swift command-line following option:
-Xcc "-sysroot <msysroot>", but now I get error:

<my swift include path>/glibc/module.map:187:14: error: header '/usr/include/sys/ioctl.h' not found
������header "/usr/include/sys/ioctl.h"
�������������^
<unknown>:0: error: could not build Objective-C module 'SwiftGlibc'

I checked, that file <mysysroot>/usr/include/sys/ioctl.h actually exists. Could you hint, what I do wrong?

25.03.2016, 01:15, "Dmitri Gribenko" <gribozavr@gmail.com>:

�Then you should have a module map for Glibc in the build products.

�Dmitri

�On Thu, Mar 24, 2016 at 2:32 PM, ���� ���� <itrub@yandex.ru> wrote:

��I have built all targets for arm (including modules and libraries) within the native arm environment on arm-emulator with chroot.

��25.03.2016, 00:25, "Dmitri Gribenko" <gribozavr@gmail.com>:

��On Thu, Mar 24, 2016 at 2:03 PM, ���� ���� <itrub@yandex.ru> wrote:

���Thanks for your answer, Dmitry. I will look for examples of module maps in test sources.

��You shouldn't need to. If you have built Swift for arm, you should
��have the right one produced by the build system.

��How did you compile the standard library for arm?

��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>*/

�--
�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>*/

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev