Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

How to change compile parameters in local building

When local build, I got some errors :

note: expected 'const char *' but argument is of type 'const unsigned char *'

I need to ignore such errors.
How to add compile parameters like:

CFLAGS += -Wno-error=unused-label -Wno-error=return-type -Wno-error=missing-braces -Wno-error=pointer-sign -Wno-error=parentheses -I./include

Comments

  • rojerrojer Dublin, Ireland
    edited May 16

    this should work:

    build_vars:
      APP_CFLAGS: "-Wfoo=bar -Wbar=baz"
    

    however, i recommend that you consider, you know, fixing warnings instead.

  • aiferaifer China

    I set the APP_CFLAGS in mos.yml like this:

    APP_CFLAGS: "-Wno-error=pointer-sign"
    

    But I also get [-Werror=pointer-sign] errors:

     error: pointer targets in passing argument 1 of 'unalChar' differ in signedness [-Werror=pointer-sign]
    

    It seems APP_CFLAGS doesn't work?

  • rojerrojer Dublin, Ireland

    hm. i tested and it worked for me. however, i went ahead and did a small refactoring (here), so now i know for sure flags are passed correctly. note that APP_CFLAGS and APP_CXXFLAGS are different, so if you're compiling a .cpp file, you need to specify APP_CXXFLAGS.

  • aiferaifer China

    Thank you. I'll try.

  • aiferaifer China
    edited May 21

    Today, I clone the latest version of mongoose-os, and build a project with -Wint-conversion errors:

    /app/src/components/common/common_buffer.c:185:12: error: comparison between pointer and integer [-Werror]
         if(pos > buf->fill_pos) {
                ^
    /app/src/components/common/common_buffer.c:192:19: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         buf->read_pos = pos;
                       ^

    Then I add APP_CFLAGS and APP_CXXFLAGS in mos.yml:

    build_vars:
    APP_CFLAGS: "-Wno-error=int-conversion -Wno-error=implicit-function-declaration -Wno-error=maybe-uninitialized -Wno-error=unused-label"
    APP_CXXFLAGS: "-Wno-error=int-conversion -Wno-error=implicit-function-declaration -Wno-error=maybe-uninitialized -Wno-error=unused-label"

    Yet, -Wint-conversion errors is reported also, APP_CFLAGS and APP_CXXFLAGS doesn't work.

    ( I use docker to do local build : mos build --local --repo $MOSPATH --verbose --arch esp32,
    and $MOSPATH is ok.
    aifer$ echo $MOSPATH
    /Users/aifer/Documents/DevSpace/mos/mongoose-os-170521
    )

  • rojerrojer Dublin, Ireland
    edited May 21

    this may just be a copy-paste artifact, but just to make sure: do you have spaces before APP_CFALGS and APP_CXX_FLAGS in mos.yml?
    it must be like this:

    build_vars:
      APP_CFLAGS: ...
      APP_CXXFLAGS: ...
    

    only then do these vars get into the build_vars dict, otherwise they just become top-level keys along with build_vars and serve no function.

  • aiferaifer China

    Yes, there is one space before APP_CFLAGS and APP_CXX_FLAGS.

  • rojerrojer Dublin, Ireland

    can you introduce an error, like add "--nosuchflag" to the value? this should break the build, nothing should compile.

  • aiferaifer China

    When building, output:
    Building...
    Docker arguments: run --rm -i -v .....'MGOS_ENABLE_WEB_CONFIG=1' 'FS_STAGING_DIR=build/fs' 'FW_DIR=build/fw' 'APP_VERSION=1.0' 'APP_CXXFLAGS=-Wno-error=int-conversion -Wno-error=implicit-function-declaration -Wno-error=maybe-uninitialized -Wno-error=unused-label' 'APP_CONF_SCHEMA=src/conf_schema.yaml' 'APP_CFLAGS=-Wno-error=int-conversion -Wno-error=implicit-function-declaration -Wno-error=maybe-uninitialized -Wno-error=unused-label' 'MGOS_ENABLE_FILE_UPLOAD=1'

  • aiferaifer China

    Why doesn't it work?

  • rojerrojer Dublin, Ireland

    is this esp32 or esp8266?

  • aiferaifer China

    @rojer
    Yes , "--nosuchflag" break the build,.
    xtensa-esp32-elf-gcc: error: unrecognized command line option '--nosuchflag'

  • aiferaifer China
    edited May 21

    In mongoose-os-170521/fw/platforms/esp32/Makefile.build,

    # Flags for other component builds, including SPIFFS, go here.
    CFLAGS += -Wall -Werror -mtext-section-literals \
              -DCS_SPIFFS_ENABLE_VFS -I$(MGOS_PATH) \
              -DSPIFFS_ON_PAGE_MOVE_HOOK=esp_spiffs_on_page_move_hook
    

    If I delete -Werror here, no warning is treated as errors.
    Can I add my own flasgs here?

  • aiferaifer China

    Add Flags here doesn't work , but delete -Werror here ok.

  • aiferaifer China

    It seems that if In mongoose-os/fw/platforms/esp32/Makefile.build, the CFLAGS contain -Werror, the CFLAGS /CXXFLAGS in mos.yml won't work.
    CFLAGS += -Wall -Werror -mtext-section-literals \
    -DCS_SPIFFS_ENABLE_VFS -I$(MGOS_PATH) \
    -DSPIFFS_ON_PAGE_MOVE_HOOK=esp_spiffs_on_page_move_hook

    After delte the -Werror in Makefile.build/CFLAGS, the CFLAGS /CXXFLAGS in mos.yml will work.

  • rojerrojer Dublin, Ireland

    well, removing -Werror of course makes warnings non-fatal. so we established that APP_CFLAGS are being passed to command line, it's just that inhibiting certain warnings does not work for some reason.
    i'll take a look at it later.

Sign In or Register to comment.