diff mbox

[OpenWrt-Devel] _GNU_SOURCE should be defined for building vs uClibc

Message ID 1464026248-23499-1-git-send-email-abrodkin@synopsys.com
State Changes Requested
Headers show

Commit Message

Alexey Brodkin May 23, 2016, 5:57 p.m. UTC
In uClibc-ng O_PATH and O_DIRECTORY are only defined if _GNU_SOURCE is
defined.

So explicitly define _GNU_SOURCE in sources that use O_PATH and
O_DIRECTORY.

Without that extra definition that's what happens when building procd.

utils/utils.c:
------------------------->8----------------------
.../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:
In function 'patch_fd':
.../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:168:22:
error: 'O_PATH' undeclared (first use in this function)
   dfd = open("/dev", O_PATH|O_DIRECTORY);
                      ^
.../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:168:22:
note: each undeclared identifier is reported only once for each function
it appears in
.../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:168:29:
error: 'O_DIRECTORY' undeclared (first use in this function)
   dfd = open("/dev", O_PATH|O_DIRECTORY);
                             ^
CMakeFiles/init.dir/build.make:182: recipe for target
'CMakeFiles/init.dir/utils/utils.c.o' failed
------------------------->8----------------------

inittab.c:
------------------------->8----------------------
.../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:
In function 'dev_exist':
.../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:72:21:
error: 'O_PATH' undeclared (first use in this function)
  dfd = open("/dev", O_PATH|O_DIRECTORY);
                     ^
.../git/openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:72:21:
note: each undeclared identifier is reported only once for each function
it appears in
.../git/openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:72:28:
error: 'O_DIRECTORY' undeclared (first use in this function)
  dfd = open("/dev", O_PATH|O_DIRECTORY);
                            ^
CMakeFiles/procd.dir/build.make:134: recipe for target
'CMakeFiles/procd.dir/inittab.c.o' failed
make[6]: *** [CMakeFiles/procd.dir/inittab.c.o] Error 1
------------------------->8----------------------

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Waldemar Brodkorb <wbx@openadk.org>
Cc: John Crispin <john@phrozen.org>
Cc: Jo-Philipp Wich <jo@mein.io>
---
 inittab.c     | 1 +
 utils/utils.c | 1 +
 2 files changed, 2 insertions(+)

Comments

John Crispin May 23, 2016, 6:03 p.m. UTC | #1
Hi,
is it really a gnu extension or is uclibc b0rked for these symbols ?

	John

On 23/05/2016 19:57, Alexey Brodkin wrote:
> In uClibc-ng O_PATH and O_DIRECTORY are only defined if _GNU_SOURCE is
> defined.
> 
> So explicitly define _GNU_SOURCE in sources that use O_PATH and
> O_DIRECTORY.
> 
> Without that extra definition that's what happens when building procd.
> 
> utils/utils.c:
> ------------------------->8----------------------
> .../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:
> In function 'patch_fd':
> .../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:168:22:
> error: 'O_PATH' undeclared (first use in this function)
>    dfd = open("/dev", O_PATH|O_DIRECTORY);
>                       ^
> .../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:168:22:
> note: each undeclared identifier is reported only once for each function
> it appears in
> .../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/utils/utils.c:168:29:
> error: 'O_DIRECTORY' undeclared (first use in this function)
>    dfd = open("/dev", O_PATH|O_DIRECTORY);
>                              ^
> CMakeFiles/init.dir/build.make:182: recipe for target
> 'CMakeFiles/init.dir/utils/utils.c.o' failed
> ------------------------->8----------------------
> 
> inittab.c:
> ------------------------->8----------------------
> .../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:
> In function 'dev_exist':
> .../openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:72:21:
> error: 'O_PATH' undeclared (first use in this function)
>   dfd = open("/dev", O_PATH|O_DIRECTORY);
>                      ^
> .../git/openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:72:21:
> note: each undeclared identifier is reported only once for each function
> it appears in
> .../git/openwrt/build_dir/target-arc_arc700_uClibc-1.0.14/procd-2016-05-19/inittab.c:72:28:
> error: 'O_DIRECTORY' undeclared (first use in this function)
>   dfd = open("/dev", O_PATH|O_DIRECTORY);
>                             ^
> CMakeFiles/procd.dir/build.make:134: recipe for target
> 'CMakeFiles/procd.dir/inittab.c.o' failed
> make[6]: *** [CMakeFiles/procd.dir/inittab.c.o] Error 1
> ------------------------->8----------------------
> 
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Waldemar Brodkorb <wbx@openadk.org>
> Cc: John Crispin <john@phrozen.org>
> Cc: Jo-Philipp Wich <jo@mein.io>
> ---
>  inittab.c     | 1 +
>  utils/utils.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/inittab.c b/inittab.c
> index 528396e..6dde11a 100644
> --- a/inittab.c
> +++ b/inittab.c
> @@ -12,6 +12,7 @@
>   * GNU General Public License for more details.
>   */
>  
> +#define _GNU_SOURCE
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  #include <sys/ioctl.h>
> diff --git a/utils/utils.c b/utils/utils.c
> index e2e3396..8f14aad 100644
> --- a/utils/utils.c
> +++ b/utils/utils.c
> @@ -12,6 +12,7 @@
>   * GNU General Public License for more details.
>   */
>  
> +#define _GNU_SOURCE
>  #include <libubox/avl.h>
>  #include <libubox/avl-cmp.h>
>  #include "utils.h"
>
Felix Fietkau May 23, 2016, 6:11 p.m. UTC | #2
On 2016-05-23 20:03, John Crispin wrote:
> Hi,
> is it really a gnu extension or is uclibc b0rked for these symbols ?
At least O_PATH is Linux specific, so defining _GNU_SOURCE makes sense.

- Felix
John Crispin May 23, 2016, 6:37 p.m. UTC | #3
On 23/05/2016 20:12, Waldemar Brodkorb wrote:
> Hi John,
> John Crispin wrote,
> 
>> Hi,
>> is it really a gnu extension or is uclibc b0rked for these symbols ?
> 
> I think it isn't b0rked.
> It was added for ARM GNU libc here under #ifdef __USE_GNU:
> https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=sysdeps/unix/sysv/linux/arm/bits/fcntl.h;h=aa2d36ca80f0ca4c5793b28b3852ce60b5fe57ef;hp=6a5f89ad1f8bdf8a825fc1e55a84679a86349a6c;hb=adb252daea96e7e160553703d477b76ff6a7781e;hpb=01b5049d107460f5eca797eda983958d1a410ffd
> 
> And later moved to generic fcntl.h file. So we are correct here or
> at least compatible to GNU libc.
> 
> best regards
>  Waldemar
>  

ok, i'll merge it later today or in the morning

	John
Karl Palsson June 1, 2016, 4:01 p.m. UTC | #4
John Crispin <john@phrozen.org> wrote:
> 
> 
> On 23/05/2016 20:12, Waldemar Brodkorb wrote:
> > Hi John,
> > John Crispin wrote,
> > 
> >> Hi,
> >> is it really a gnu extension or is uclibc b0rked for these symbols ?
> > 
> > I think it isn't b0rked.
> > It was added for ARM GNU libc here under #ifdef __USE_GNU:
> > https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=sysdeps/unix/sysv/linux/arm/bits/fcntl.h;h=aa2d36ca80f0ca4c5793b28b3852ce60b5fe57ef;hp=6a5f89ad1f8bdf8a825fc1e55a84679a86349a6c;hb=adb252daea96e7e160553703d477b76ff6a7781e;hpb=01b5049d107460f5eca797eda983958d1a410ffd
> > 
> > And later moved to generic fcntl.h file. So we are correct here or
> > at least compatible to GNU libc.
> > 
> > best regards
> >  Waldemar
> >  
> 
> ok, i'll merge it later today or in the morning
> 

This still doesn't work on the uclibc in openwrt-CC branch. The
O_PATH definitions are in asm-generic/fcntl.h, which can be
included via linux/fcntl.h, _GNU_SOURCE doesn't get this pulled
in though.

I attempted to add includes for linux/fcntl, but it just gives me
redeclaration errors for struct flock.

Cheers,
Karl P
diff mbox

Patch

diff --git a/inittab.c b/inittab.c
index 528396e..6dde11a 100644
--- a/inittab.c
+++ b/inittab.c
@@ -12,6 +12,7 @@ 
  * GNU General Public License for more details.
  */
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
diff --git a/utils/utils.c b/utils/utils.c
index e2e3396..8f14aad 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -12,6 +12,7 @@ 
  * GNU General Public License for more details.
  */
 
+#define _GNU_SOURCE
 #include <libubox/avl.h>
 #include <libubox/avl-cmp.h>
 #include "utils.h"