#858 configure: Add method of appending complier flags without overriding them.

Reporter Dennis Schridde
Owner Zash
Created
Updated
Stars ★ (1)  
Tags
  • Type-Enhancement
  • Component-Scripts
  • Milestone-0.10
  • Status-Fixed
  • Priority-Medium
  1. Dennis Schridde on

    What steps will reproduce the problem? 1. Try to compile prosody with a compiler defaulting to C89 2. Observe build error What is the expected output? What do you see instead? I expect no compile time error, but I see one. What version of the product are you using? On what operating system? 0.10 from Hg on Linux Please provide any additional information below. ``` x86_64-pc-linux-gnu-gcc -pipe -mtune=generic -O2 -D_GNU_SOURCE -Wall -fPIC -I/usr/include -c -o table.o table.c table.c: In function ‘Lpack’: table.c:14:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode for(int arg = n_args; arg >= 1; arg--) { ^ table.c:14:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code make[1]: *** [<builtin>: table.o] Error 1 ``` If you use C99 (as it appears you intent to, judging from 582bfb39337f), you should put the compiler in C99 mode by supplying the right flags.

  2. Zash on

    What are your configure flags? C99 mode was set by default in https://hg.prosody.im/0.10/rev/96fa5ef5d613

    Changes
    • tags Milestone-0.10
    • owner Zash
  3. Dennis Schridde on

    I use(d) the following, among others, to be able to prepend my own C/LDFLAGS to the ones prosody needs: --cflags="${CFLAGS} -Wall -fPIC -D_GNU_SOURCE" \ --ldflags="${LDFLAGS} -shared" \ "Used", because now I also append -std=c99 to the list. With other buildsystems we can set CFLAGS/LDFLAGS on the command line, e.g. `./configure CFLAGS=...` and they will be prepended, because the build rules are of the following style, where the package's build system sets AM_CFLAGS, and the user sets CFLAGS: .o: .c $(CC) $(CFLAGS) $(AM_CFLAGS) -o $@ $< Is something like this also possible with Prosody?

  4. Zash on

    Not with the current configure script. I started looking into adding an option to configure for appending CFLAGS. However it'd be preferable to not diverge too much from the "upstream" LuaRocks configure file that this is based on.

  5. Dennis Schridde on

    Maybe we can together change the upstream LuaRocks example / default file? I think other projects could also benefit from this addition.

  6. Zash on

    This seems related: https://github.com/luarocks/luarocks/issues/129 LuaRocks itself doesn't actually use those flags for itself like we do, they are used when building binary modules from rocks. I'll convert this issue into a feature request for now.

    Changes
    • title table.c:14:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode configure: Add method of appending complier flags without overriding them.
    • tags Type-Defect Status-Accepted Type-Enhancement
  7. Zash on

    Changes
    • tags Component-Scripts
  8. Zash on

    Added these: https://hg.prosody.im/0.10/rev/69f8b22b0472 https://hg.prosody.im/0.10/rev/12440a0043ab

    Changes
    • tags Status-Fixed

New comment