All of lore.kernel.org
 help / color / mirror / Atom feed
* Cross-compile for arm architecture
@ 2015-02-25 15:42 Emre Can Kucukoglu
  2015-02-25 18:25 ` Stephen Smalley
  0 siblings, 1 reply; 5+ messages in thread
From: Emre Can Kucukoglu @ 2015-02-25 15:42 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]

Hello,

I want to use SELinux for my experimental vanilla kernel distribution in
Pandaboard ES. To achieve that I have configured my kernel for SELinux
support. Then, I have recently cloned selinux userspace repository to
cross-compile it for arm architecture. I use arm-linux-gnueabi toolchain in
Ubuntu 14.04 workstation.

$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabi-

As mentioned in readme instruction,

$ make DESTDIR=~/obj install install-pywrap

command is used, however due to -Werror flags in various Makefile's, error
is thrown:

dispol.c: In function ‘main’:
dispol.c:452:8: error: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result [-Werror=unused-result]
   fgets(ans, sizeof(ans), stdin);
        ^
dispol.c:479:9: error: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result [-Werror=unused-result]
    fgets(ans, sizeof(ans), stdin);
         ^
dispol.c:490:9: error: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result [-Werror=unused-result]
    fgets(ans, sizeof(ans), stdin);
         ^
dispol.c:517:9: error: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result [-Werror=unused-result]
    fgets(OutfileName, sizeof(OutfileName), stdin);
         ^
cc1: all warnings being treated as errors
make[2]: *** [dispol.o] Error 1

I did this modification to get over this error which is caused by -Werror
flag:

char *fgetsret; /* error is given, because return value is not captured */
fgetsret = fgets(...);
if (!fgetsret) { /* if fgetsret is not used, another error comes from
warning */
// some exit message
exit(1);
}

Did I miss something about SELinux cross-compilation for an arm
architecture, since constantly I'm taking errors.
-- 
Emre Can Kucukoglu

[-- Attachment #2: Type: text/html, Size: 2415 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross-compile for arm architecture
  2015-02-25 15:42 Cross-compile for arm architecture Emre Can Kucukoglu
@ 2015-02-25 18:25 ` Stephen Smalley
  2015-03-03 15:03   ` Emre Can Kucukoglu
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Smalley @ 2015-02-25 18:25 UTC (permalink / raw)
  To: Emre Can Kucukoglu, selinux

On 02/25/2015 10:42 AM, Emre Can Kucukoglu wrote:
> Hello,
> 
> I want to use SELinux for my experimental vanilla kernel distribution in
> Pandaboard ES. To achieve that I have configured my kernel for SELinux
> support. Then, I have recently cloned selinux userspace repository to
> cross-compile it for arm architecture. I use arm-linux-gnueabi toolchain
> in Ubuntu 14.04 workstation. 
> 
> $ export ARCH=arm
> $ export CROSS_COMPILE=arm-linux-gnueabi-
> 
> As mentioned in readme instruction, 
> 
> $ make DESTDIR=~/obj install install-pywrap
> 
> command is used, however due to -Werror flags in various Makefile's,
> error is thrown: 
> 
> dispol.c: In function ‘main’:
> dispol.c:452:8: error: ignoring return value of ‘fgets’, declared with
> attribute warn_unused_result [-Werror=unused-result]
>    fgets(ans, sizeof(ans), stdin);
>         ^
> dispol.c:479:9: error: ignoring return value of ‘fgets’, declared with
> attribute warn_unused_result [-Werror=unused-result]
>     fgets(ans, sizeof(ans), stdin);
>          ^
> dispol.c:490:9: error: ignoring return value of ‘fgets’, declared with
> attribute warn_unused_result [-Werror=unused-result]
>     fgets(ans, sizeof(ans), stdin);
>          ^
> dispol.c:517:9: error: ignoring return value of ‘fgets’, declared with
> attribute warn_unused_result [-Werror=unused-result]
>     fgets(OutfileName, sizeof(OutfileName), stdin);
>          ^
> cc1: all warnings being treated as errors
> make[2]: *** [dispol.o] Error 1
> 
> I did this modification to get over this error which is caused by
> -Werror flag:
> 
> char *fgetsret; /* error is given, because return value is not captured */
> fgetsret = fgets(...);
> if (!fgetsret) { /* if fgetsret is not used, another error comes from
> warning */
> // some exit message
> exit(1);
> }
> 
> Did I miss something about SELinux cross-compilation for an arm
> architecture, since constantly I'm taking errors.

Hmm...that's interesting.  Builds just fine on Fedora 20.  I do however
get the same error building on Ubuntu 14.04 (which is not something we
typically test on; most SELinux developers work on Fedora).

Willing to accept patches to fix it, but it is merely a test/debugging
program that you can even exclude from your build if you like.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross-compile for arm architecture
  2015-02-25 18:25 ` Stephen Smalley
@ 2015-03-03 15:03   ` Emre Can Kucukoglu
  2015-03-03 20:08     ` Stephen Smalley
  0 siblings, 1 reply; 5+ messages in thread
From: Emre Can Kucukoglu @ 2015-03-03 15:03 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 4485 bytes --]

Now, I'm working with Fedora 21. However another error exists now:

Toolchain: gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux

export
PATH=$PATH:/home/ecank/1511/toolchain/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin
export CC=arm-linux-gnueabihf-gcc
export CROSS_COMPILE=arm-linux-gnueabihf-
export CFLAGS=-D__thread=
export EMBEDDED=y
export DESTDIR=~/obj
make install install-pywrap

arm-linux-gnueabihf-gcc: error: unrecognized command line option
‘-mno-tls-direct-seg-refs’
Makefile:130: recipe for target 'is_customizable_type.o' failed
make[2]: *** [is_customizable_type.o] Error 1
make[2]: Leaving directory '/home/ecank/1511/selinux/libselinux/src'
Makefile:28: recipe for target 'install' failed

all output: http://pastebin.com/U03hhtJJ

moreover:
$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro
GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Then after deletion of
TLSFLAGS += -mno-tls-direct-seg-refs
(i deleted that flag, since it was related with x86-64 and i386)
(https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/i386-and-x86-64-Options.html)

New error is related with pcre library.

arm-linux-gnueabihf-gcc -D__thread= -I../include
-I/home/ecank/obj/usr/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-DDISABLE_AVC -DDISABLE_BOOL -DDISABLE_RPM -DDISABLE_SETRANS  -c -o
label_file.o label_file.c
label_file.c:21:18: fatal error: pcre.h: No such file or directory
 #include <pcre.h>
                  ^
compilation terminated.
Makefile:130: recipe for target 'label_file.o' failed

all output: http://pastebin.com/9rxKFvLL

Really need help about compiling SELinux for an arm.

Thanks in advance.


2015-02-25 20:25 GMT+02:00 Stephen Smalley <sds@tycho.nsa.gov>:

> On 02/25/2015 10:42 AM, Emre Can Kucukoglu wrote:
> > Hello,
> >
> > I want to use SELinux for my experimental vanilla kernel distribution in
> > Pandaboard ES. To achieve that I have configured my kernel for SELinux
> > support. Then, I have recently cloned selinux userspace repository to
> > cross-compile it for arm architecture. I use arm-linux-gnueabi toolchain
> > in Ubuntu 14.04 workstation.
> >
> > $ export ARCH=arm
> > $ export CROSS_COMPILE=arm-linux-gnueabi-
> >
> > As mentioned in readme instruction,
> >
> > $ make DESTDIR=~/obj install install-pywrap
> >
> > command is used, however due to -Werror flags in various Makefile's,
> > error is thrown:
> >
> > dispol.c: In function ‘main’:
> > dispol.c:452:8: error: ignoring return value of ‘fgets’, declared with
> > attribute warn_unused_result [-Werror=unused-result]
> >    fgets(ans, sizeof(ans), stdin);
> >         ^
> > dispol.c:479:9: error: ignoring return value of ‘fgets’, declared with
> > attribute warn_unused_result [-Werror=unused-result]
> >     fgets(ans, sizeof(ans), stdin);
> >          ^
> > dispol.c:490:9: error: ignoring return value of ‘fgets’, declared with
> > attribute warn_unused_result [-Werror=unused-result]
> >     fgets(ans, sizeof(ans), stdin);
> >          ^
> > dispol.c:517:9: error: ignoring return value of ‘fgets’, declared with
> > attribute warn_unused_result [-Werror=unused-result]
> >     fgets(OutfileName, sizeof(OutfileName), stdin);
> >          ^
> > cc1: all warnings being treated as errors
> > make[2]: *** [dispol.o] Error 1
> >
> > I did this modification to get over this error which is caused by
> > -Werror flag:
> >
> > char *fgetsret; /* error is given, because return value is not captured
> */
> > fgetsret = fgets(...);
> > if (!fgetsret) { /* if fgetsret is not used, another error comes from
> > warning */
> > // some exit message
> > exit(1);
> > }
> >
> > Did I miss something about SELinux cross-compilation for an arm
> > architecture, since constantly I'm taking errors.
>
> Hmm...that's interesting.  Builds just fine on Fedora 20.  I do however
> get the same error building on Ubuntu 14.04 (which is not something we
> typically test on; most SELinux developers work on Fedora).
>
> Willing to accept patches to fix it, but it is merely a test/debugging
> program that you can even exclude from your build if you like.
>
>


-- 
Emre Can Kucukoglu

[-- Attachment #2: Type: text/html, Size: 5949 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross-compile for arm architecture
  2015-03-03 15:03   ` Emre Can Kucukoglu
@ 2015-03-03 20:08     ` Stephen Smalley
  2015-03-03 20:38       ` Stephen Smalley
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Smalley @ 2015-03-03 20:08 UTC (permalink / raw)
  To: Emre Can Kucukoglu, selinux

On 03/03/2015 10:03 AM, Emre Can Kucukoglu wrote:
> Now, I'm working with Fedora 21. However another error exists now:
> 
> Toolchain: gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux
> 
> export
> PATH=$PATH:/home/ecank/1511/toolchain/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin
> export CC=arm-linux-gnueabihf-gcc
> export CROSS_COMPILE=arm-linux-gnueabihf-
> export CFLAGS=-D__thread= 
> export EMBEDDED=y
> export DESTDIR=~/obj
> make install install-pywrap
> 
> arm-linux-gnueabihf-gcc: error: unrecognized command line option
> ‘-mno-tls-direct-seg-refs’
> Makefile:130: recipe for target 'is_customizable_type.o' failed
> make[2]: *** [is_customizable_type.o] Error 1
> make[2]: Leaving directory '/home/ecank/1511/selinux/libselinux/src'
> Makefile:28: recipe for target 'install' failed
> 
> all output: http://pastebin.com/U03hhtJJ
> 
> moreover:
> $ arm-linux-gnueabihf-gcc --version
> arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro
> GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
> Copyright (C) 2014 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> Then after deletion of
> TLSFLAGS += -mno-tls-direct-seg-refs
> (i deleted that flag, since it was related with x86-64 and i386) 
> (https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/i386-and-x86-64-Options.html)
> 
> New error is related with pcre library.
> 
> arm-linux-gnueabihf-gcc -D__thread= -I../include
> -I/home/ecank/obj/usr/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
> -DDISABLE_AVC -DDISABLE_BOOL -DDISABLE_RPM -DDISABLE_SETRANS  -c -o
> label_file.o label_file.c
> label_file.c:21:18: fatal error: pcre.h: No such file or directory
>  #include <pcre.h>
>                   ^
> compilation terminated.
> Makefile:130: recipe for target 'label_file.o' failed
> 
> all output: http://pastebin.com/9rxKFvLL
> 
> Really need help about compiling SELinux for an arm.

Looks like you just don't have pcre-devel installed?

There have been various ports of SELinux to ARM in the past, but I think
they always involved modifications of some sort.  Most notably the port
of SELinux to Android, see:
http://seandroid.bitbucket.org/index.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross-compile for arm architecture
  2015-03-03 20:08     ` Stephen Smalley
@ 2015-03-03 20:38       ` Stephen Smalley
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Smalley @ 2015-03-03 20:38 UTC (permalink / raw)
  To: Emre Can Kucukoglu, selinux

On 03/03/2015 03:08 PM, Stephen Smalley wrote:
> On 03/03/2015 10:03 AM, Emre Can Kucukoglu wrote:
>> Now, I'm working with Fedora 21. However another error exists now:
>>
>> Toolchain: gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux
>>
>> export
>> PATH=$PATH:/home/ecank/1511/toolchain/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin
>> export CC=arm-linux-gnueabihf-gcc
>> export CROSS_COMPILE=arm-linux-gnueabihf-
>> export CFLAGS=-D__thread= 
>> export EMBEDDED=y
>> export DESTDIR=~/obj
>> make install install-pywrap
>>
>> arm-linux-gnueabihf-gcc: error: unrecognized command line option
>> ‘-mno-tls-direct-seg-refs’
>> Makefile:130: recipe for target 'is_customizable_type.o' failed
>> make[2]: *** [is_customizable_type.o] Error 1
>> make[2]: Leaving directory '/home/ecank/1511/selinux/libselinux/src'
>> Makefile:28: recipe for target 'install' failed
>>
>> all output: http://pastebin.com/U03hhtJJ
>>
>> moreover:
>> $ arm-linux-gnueabihf-gcc --version
>> arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro
>> GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
>> Copyright (C) 2014 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions.  There is NO
>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>
>> Then after deletion of
>> TLSFLAGS += -mno-tls-direct-seg-refs
>> (i deleted that flag, since it was related with x86-64 and i386) 
>> (https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/i386-and-x86-64-Options.html)
>>
>> New error is related with pcre library.
>>
>> arm-linux-gnueabihf-gcc -D__thread= -I../include
>> -I/home/ecank/obj/usr/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
>> -DDISABLE_AVC -DDISABLE_BOOL -DDISABLE_RPM -DDISABLE_SETRANS  -c -o
>> label_file.o label_file.c
>> label_file.c:21:18: fatal error: pcre.h: No such file or directory
>>  #include <pcre.h>
>>                   ^
>> compilation terminated.
>> Makefile:130: recipe for target 'label_file.o' failed
>>
>> all output: http://pastebin.com/9rxKFvLL
>>
>> Really need help about compiling SELinux for an arm.
> 
> Looks like you just don't have pcre-devel installed?
> 
> There have been various ports of SELinux to ARM in the past, but I think
> they always involved modifications of some sort.  Most notably the port
> of SELinux to Android, see:
> http://seandroid.bitbucket.org/index.html

There is also the meta-selinux layer for the Yocto project,
That was created by others and does reuse the upstream selinux userspace
and refpolicy, unlike the port to Android which took a much more
minimalist, nativized approach.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-03 20:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-25 15:42 Cross-compile for arm architecture Emre Can Kucukoglu
2015-02-25 18:25 ` Stephen Smalley
2015-03-03 15:03   ` Emre Can Kucukoglu
2015-03-03 20:08     ` Stephen Smalley
2015-03-03 20:38       ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.