hercules-team / augeas

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
486 stars 199 forks source link

BLD issue for augeas-1.6.0/src/fa.c and how some of the macros are used. #424

Open aixtools opened 7 years ago

aixtools commented 7 years ago

With this define:

32 37 | #define list_for_each(iter, list) \ 32 38 | for (typeof(list) (iter) = list; (iter) != NULL; (iter) = (iter)->next) 32 39 |

AIX xlc - does not understand the undefined variable "s" (and "p" in other routines) (in ../. ./src/augeas-1.6.0/src/fa.c)

Note: in the listing below the format is: XXXX | original text XXXX + code after macro processing when suitable, followed by error messages

  398 | static void gut(struct fa *fa) {
  399 |     list_for_each(s, fa->initial) {
  399 +     for (typeof(fa->initial) (s) = fa->initial; (s) != 0; (s) = (s)->next) {
  "../../src/augeas-1.6.0/src/fa.c", line 399.5: 1506-023 (S) Expecting function or pointer to function.
  "../../src/augeas-1.6.0/src/fa.c", line 399.5: 1506-045 (S) Undeclared identifier s.
  400 |         free_trans(s);
  401 |     }
  402 |     list_free(fa->initial);
  402 +     while ((fa->initial) != 0) { typeof(fa->initial) _p = fa->initial; (fa->initial) = (fa->initial)->next; free((void *) _p); };
  "../../src/augeas-1.6.0/src/fa.c", line 402.5: 1506-277 (S) Syntax error: possible missing ';' or ','?
  "../../src/augeas-1.6.0/src/fa.c", line 402.5: 1506-045 (S) Undeclared identifier _p.
  403 |     fa->initial = NULL;
  403 +     fa->initial = 0;
  404 | }

Note: many of the flags here are ignored/useless for xlc, e.g., -std=gnu99. Also, setting the standard to gnu rather than c (e.g., c99) is not advantageous for portability.

xlc -DHAVE_CONFIG_H -I. -I../../src/augeas-1.6.0/src -I.. -I/opt/include -D_THREAD_SAFE -std=gnu99 -I ../gnulib/lib -I ../../src/augeas-1.6.0/gnulib/lib -I/opt/include/libxml2 -I/opt/include -qmaxmem=-1 -qarch=pwr4 -I/opt/include -c ../. ./src/augeas-1.6.0/src/fa.c -Wp,-qmakedep=gcc,-MF.deps/fa.TPlo -DPIC -o .libs/fa.o

FYI - to get the listing info above I added the (xlc) flags -qsource -qshowinc Michael

=== The complete message output is: xlc -DHAVE_CONFIG_H -I. -I../../src/augeas-1.6.0/src -I.. -I/opt/include -D_THREAD_SAFE -std=gnu99 -I ../gnulib/lib -I ../../src/augeas-1.6.0/gnulib/lib -I/opt/include/libxml2 -I/opt/include -qmaxmem=-1 -qarch=pwr4 -I/opt/include -c ../../src/augeas-1.6.0/src/fa.c -Wp,-qmakedep=gcc,-MF.deps/fa.TPlo -DPIC -o .libs/fa.o xlc: 1501-210 (W) command option t contains an incorrect subargument "../../src/augeas-1.6.0/src/fa.c", line 399.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 399.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 402.5: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 402.5: 1506-045 (S) Undeclared identifier _p. "../../src/augeas-1.6.0/src/fa.c", line 428.13: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 428.13: 1506-045 (S) Undeclared identifier _e. "../../src/augeas-1.6.0/src/fa.c", line 479.5: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 479.5: 1506-045 (S) Undeclared identifier _e. "../../src/augeas-1.6.0/src/fa.c", line 479.5: 1506-275 (S) Unexpected text _p encountered. "../../src/augeas-1.6.0/src/fa.c", line 479.5: 1506-045 (S) Undeclared identifier _p. "../../src/augeas-1.6.0/src/fa.c", line 480.5: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 487.5: 1506-275 (S) Unexpected text _p encountered. "../../src/augeas-1.6.0/src/fa.c", line 487.5: 1506-045 (S) Undeclared identifier _p. "../../src/augeas-1.6.0/src/fa.c", line 853.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 853.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 885.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 885.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 907.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 907.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 927.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 927.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 933.9: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1024.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1024.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 1136.5: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 1136.5: 1506-045 (S) Undeclared identifier _e. "../../src/augeas-1.6.0/src/fa.c", line 1190.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1190.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 1231.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1231.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 1270.9: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1270.9: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 1273.9: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 1273.9: 1506-045 (S) Undeclared identifier _p. "../../src/augeas-1.6.0/src/fa.c", line 1431.9: 1506-277 (S) Syntax error: possible missing ';' or ','? "../../src/augeas-1.6.0/src/fa.c", line 1431.9: 1506-045 (S) Undeclared identifier _p. "../../src/augeas-1.6.0/src/fa.c", line 1476.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1476.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 1895.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1895.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 1987.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 1987.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2075.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2075.5: 1506-045 (S) Undeclared identifier p. "../../src/augeas-1.6.0/src/fa.c", line 2165.17: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2165.17: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2180.13: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2203.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2203.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2398.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2398.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2427.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2427.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2462.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2462.5: 1506-045 (S) Undeclared identifier a. "../../src/augeas-1.6.0/src/fa.c", line 2723.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2723.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2771.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2771.5: 1506-045 (S) Undeclared identifier p. "../../src/augeas-1.6.0/src/fa.c", line 2808.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2808.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 2823.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 2823.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 3136.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 3136.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 3184.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 3184.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 3210.9: 1506-046 (S) Syntax error. "../../src/augeas-1.6.0/src/fa.c", line 3210.9: 1506-122 (S) Expecting pointer to struct or union. "../../src/augeas-1.6.0/src/fa.c", line 3210.9: 1506-046 (S) Syntax error. "../../src/augeas-1.6.0/src/fa.c", line 4080.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4080.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 4085.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4194.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4194.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 4217.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4226.9: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4226.9: 1506-045 (S) Undeclared identifier s1. "../../src/augeas-1.6.0/src/fa.c", line 4259.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4476.5: 1506-023 (S) Expecting function or pointer to function. "../../src/augeas-1.6.0/src/fa.c", line 4476.5: 1506-045 (S) Undeclared identifier s. "../../src/augeas-1.6.0/src/fa.c", line 4488.5: 1506-023 (S) Expecting function or pointer to function.

aixtools commented 7 years ago

anyone who knows the code watching this?

I can try a guess I suppose...

aixtools commented 7 years ago

Update: it appears the syntax in list.h is gcc specific.

I wrote the following test program to experiment with xlc and gcc (on a linux system).

2016-11-04 11:33                       x.c                        Page 1

    1   struct state {
    2       struct state *next;
    3       unsigned int  accept : 1;
    4       unsigned int  live : 1;
    5       unsigned int  reachable : 1;
    6       unsigned int  visited : 1;   /* Used in various places to track progress */
    7   };
    8
    9   struct fa {
   10       struct state *initial;
   11       int           deterministic : 1;
   12       int           minimal : 1;
   13       unsigned int  nocase : 1;
   14       int           trans_re : 1;
   15   };
   16
   17   struct fa FA;
   18
   19   x(struct fa *fa)
   20   {
   21           typeof(fa->initial)     s = fa->initial;
   22           typeof(fa->initial)     v;
   23           void                    *_v;
   24           _v = fa->initial;
   25           v = (typeof(fa->initial))(s->next);
   26           v = (typeof(fa->initial))(s)->next;
   27   }

gcc has no issue with the code:

root@x066:/data/prj/aixtools/augeas-1.6.0/src# gcc -c x.c
root@x066:/data/prj/aixtools/augeas-1.6.0/src# ls x.o
x.o

However, xlc complains - with expanded source listing:

IBM XL C for AIX, Version 11.1.0.21 x.c 11/04/16 10:35:29 (C)

>>>>> SOURCE SECTION <<<<<

        1 | struct state {
        2 |     struct state *next;
        3 |     unsigned int  accept : 1;
        4 |     unsigned int  live : 1;
        5 |     unsigned int  reachable : 1;
        6 |     unsigned int  visited : 1;   /* Used in various places to track progress */
        7 | };
        8 |
        9 | struct fa {
       10 |     struct state *initial;
       11 |     int           deterministic : 1;
       12 |     int           minimal : 1;
       13 |     unsigned int  nocase : 1;
       14 |     int           trans_re : 1;
       15 | };
       16 |
       17 | struct fa FA;
       18 |
       19 | x(struct fa *fa)
       20 | {
       21 |         typeof(fa->initial)     s = fa->initial;
"x.c", line 21.33: 1506-277 (S) Syntax error: possible missing ';' or ','?
       22 |         typeof(fa->initial)     v;
"x.c", line 22.33: 1506-275 (S) Unexpected text v encountered.
       23 |         void                    *_v;
       24 |         _v = fa->initial;
       25 |         v = (typeof(fa->initial))(s->next);
"x.c", line 25.35: 1506-045 (S) Undeclared identifier s.
"x.c", line 25.13: 1506-023 (S) Expecting function or pointer to function.
"x.c", line 25.9: 1506-045 (S) Undeclared identifier v.
       26 |         v = (typeof(fa->initial))(s)->next;
"x.c", line 26.13: 1506-023 (S) Expecting function or pointer to function.
       27 | }

I shall try adding some defines that test for GCC and add changes that allow the code in list.h to work asis.

lutter commented 7 years ago

Hi Michael ! Yes, as you discovered, the Augeas source uses some gcc extensions that break on non-GNU compilers. Would it be possible for you to use gcc to build Augeas ? That might be the easiest route (and I know others have gone down that path successfully).

As for patches to make it work with xlc: if they are not too intrusive, I am more than happy to take them - but I don't have a way to verify that they will continue to work, so they might bitrot more or less quickly, depending on what changes are needed.

aixtools commented 7 years ago

On 04/11/2016 18:24, David Lutterkort wrote:

Hi Michael ! Yes, as you discovered, the Augeas source uses some gcc extensions that break on non-GNU compilers. Would it be possible for you to use gcc to build Augeas ? That might be the easiest route (and I know others have gone down that path successfully). I have no problem with gcc as a compiler. However, gcc code frequently needs a gcc run-time environment (e.g., glibc). If there are any dependancies like that it defeats the whole purpose for what I am trying to do (reduce the dependencies for cloud-init from 34-35 rpm packages to one installp package).

At the moment cloud-init is not using netcf - but when it does - netcf has a dependency on augeas.

As for patches to make it work with xlc: if they are not too intrusive, I am more than happy to take them - but I don't have a way to verify that they will continue to work, so they might bitrot more or less quickly, depending on what changes are needed. I am not a "syntax" specialist - but the key issue seems to be xlc, or perhaps better, non-gcc - do not accept (typeof(VARIABLE)) a) as an auto declaration for variable b) as a LHS prefix (i.e., I think I saw it work on RHS - been a few days since I looked at this)

So, I am thinking - as this is not likely to be a high-performance thing, to look at declaring the macros as (static) functions so the "temp" variables used now can be "locally" defined. An alturnative would be to define the variables locally in the functions the macros are used, but behind a test that the compiler is not GCC.

Both would be something - I would hope - that you could test even using gcc - by manually setting the define.

That said, my concern is whether the LHS typeof() prefixes will be accepted.

So, thanks for the reply - I'll try and make time this week to see if I can come up with a "simple" and clear patch suggestion.

Michael

aixtools commented 7 years ago

Sorry for the long delay. As far as using gcc - I suppose I could try to test it - however, I would never try and use it that way. GCC needs a large (for AIX additional) run-time environment that must be built - and maintained - and updated with every change to gcc.

I am well aware this is not a concern on GNU/Linux as there this is the default run-time environment. For me being forced to use gcc is a reason to not package 'something'.

I would greatly appreciate the adoption of a "more" portable syntax.

And once I discover how to update my fork (without deleting my fork and then forking it again) - I'll update my local copy.

Michael

MatthewHannigan commented 7 years ago

Would using gxlc help? (gcc compatibility wrapper) https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.2/com.ibm.xlc131.aix.doc/compiler_ref/rmapgxlc.html

(link fixed; not sure what happened there)

aixtools commented 7 years ago

Matthew: a) the link is not working; b) I think not - I thought it is more to translate gcc command line options to xlc command options (e.g., -mpower4 => -qpwr4).

I am going to try a rebase command to get my fork and local copy aligned with current situation, and shall "report" back.

aixtools commented 7 years ago

ok. a bit verbose perhaps: shall log a brief history of what I do (so I can repeat myself later - as I do not recall how I automated the testing of my "x.c" last November, starting over again, sortof.

After updating the fork, I "fetched" the upstream, and pushed it to my "fork".

cloned the new situation to a local copy, and using a linux system (for the gnu autotools needed to get a working configure) - ran autogen.sh

This "autogen.sh" stops with: checking for rl_initialize in -lreadline... no configure: WARNING: readline library not found configure: error: Could not find a working readline library (see config.log for details).

On AIX, configure fails with: michael@x071.home.local:[/data/prj/aixtools/github/augeas-1.8.0]./configure configure: error: cannot find install-sh, install.sh, or shtool in build/ac-aux "."/build/ac-aux

As my linux (and AIX) systems are as minimal as I can keep them - looks like I'll have to install readline and try autogen.sh again.

Update: needed libreadline-dev installed

Now ends with: checking for LIBXML... no configure: error: Package requirements (libxml-2.0) were not met:

No package 'libxml-2.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBXML_CFLAGS and LIBXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.

but AIX still cannot run configure... michael@x071.home.local:[/data/prj/aixtools/github/augeas-1.8.0]./configure configure: error: cannot find install-sh, install.sh, or shtool in build/ac-aux "."/build/ac-aux

After installing libxml2-dev - autogen.sh completes "successfully", but AIX cannot run the ./configure file generated.

config.status: creating examples/Makefile config.status: creating doc/Makefile config.status: creating doc/naturaldocs/Makefile config.status: creating augeas.pc config.status: creating augeas.spec config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands

Now type 'make' to compile augeas.

michael@x071.home.local:[/data/prj/aixtools/github/augeas-1.8.0]./configure configure: error: cannot find install-sh, install.sh, or shtool in build/ac-aux "."/build/ac-aux

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Last bit for this step (rather comment)

UPDATE2: After running "make dist" and unpacking the .tar.gz file made, ./configure runs on the AIX system.