mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
759 stars 140 forks source link

compiler for INTEGRITY OS complains about non-constant initialization of MD_LINE #71

Closed ec1oud closed 5 years ago

ec1oud commented 5 years ago

From https://testresults.qt.io/logs/qt/qtbase/7e01267e18c12cf19d8cf7487126efeeaeb84b23/LinuxRHEL_7_4x86_64INTEGRITYINTEGRITY_11_04armv7GCCqtci-linux-RHEL-7.4-x86_64-fa00a5Release_DisableTests_OpenGLES2_NoUseGoldLinker/2a48a3b7dcb9652b1532a3ad14de7580b5b9b1ee/build_1555421647/log.txt.gz

"../3rdparty/md4c/md4c.c", line 3378: warning #68-D: integer conversion
           resulted in a change of sign
                   OFF inline_link_end = -1;
                                         ^

 "../3rdparty/md4c/md4c.c", line 4155: error #28: expression must have a
           constant value
       MD_LINE line = { beg, end };
                        ^

 "../3rdparty/md4c/md4c.c", line 4155: error #28: expression must have a
           constant value
       MD_LINE line = { beg, end };
                             ^

 "../3rdparty/md4c/md4c.c", line 4246: error #28: expression must have a
           constant value
       MD_LINE line = { beg, beg };
                        ^

 "../3rdparty/md4c/md4c.c", line 4246: error #28: expression must have a
           constant value
       MD_LINE line = { beg, beg };
                             ^

 "../3rdparty/md4c/md4c.c", line 5189: warning #940-D: missing return statement
           at end of non-void function "md_is_html_block_end_condition"
   }
   ^

Host: os: Linux, osVersion: RHEL_7_4, compiler: GCC, arch: X86_64 Target: os: INTEGRITY, osVersion: INTEGRITY_11_04, compiler: GCC, arch: ARMv7

Maybe making those beg and end arguments const will satisfy it? not sure... and I don't have a development environment for testing, so we'll have to keep trying with the CI system I guess.

mity commented 5 years ago

And do you know what's the gcc version? (I guess these errors are from the compiler's front-end so using gcc of the same version on another platform could generate the same error output.)

ec1oud commented 5 years ago

0001-fixup.patch.gz

WAG patch... I'll try with CI

ec1oud commented 5 years ago

That didn't fix it. https://codereview.qt-project.org/#/c/259167/ https://testresults.qt.io/logs/qt/qtbase/412bb999ad0acfc031a4eb88bcbf6d428242959b/LinuxRHEL_7_4x86_64INTEGRITYINTEGRITY_11_04armv7GCCqtci-linux-RHEL-7.4-x86_64-707575Release_DisableTests_OpenGLES2_NoUseGoldLinker/2a48a3b7dcb9652b1532a3ad14de7580b5b9b1ee/build_1555446448/log.txt.gz

ec1oud commented 5 years ago

googling the error finds stuff like https://stackoverflow.com/questions/50399446/keil-error-28-expression-must-have-a-constant-value

mity commented 5 years ago

I guess it is rather complaining that the initializers are not compile-time constants. Old C standards required that. So I guess replacing e.g.

void somefunc(int a, int b)
{
    struct X = { a, b };
    ...
}

has to be replaced with series of normal assignments:

void somefunc(int a, int b)
{
    struct X;

    x.a = a;
    x.b = b;
    ...
}
ec1oud commented 5 years ago

Whack-a-mole session: https://codereview.qt-project.org/#/c/259167/ There are more errors after I fix some...

mity commented 5 years ago

According to this, rhel 7.4 should provide gcc 4.8.x.

I was able to get gcc 4.8.1 for Windows and with that MD4C builds fine, if I ignore some warnings, and it passes complete test suite.

The only compile-time error I can get from it is with -ansi -pedantic because it then C compiler does not support inline.

Is it possible that your CI machine uses something even older for the ARM build? If so, then I am quite surprised it does not choke anywhere else with Qt sources. C++ did evolved more rapidly in the recent years, right? Or is its code base that much conservative?

Can you check it is not e.g. some kind of mis-configuration or something; e.g. that C++ compiler is newer version then C compiler?

Especially if it is some cross-compiler toolchain, there might be some space for some troubles like that...

mity commented 5 years ago

Is it really gcc? Isn't it this?

The build log (the 1st link you provided) says the core Qt source codes are compiled with g++, but MD4C is compiled with a command called cxintarm. Is this mixing of compilers intended?

See https://github.com/openwebos/qt/blob/master/mkspecs/qws/integrity-arm-cxarm/qmake.conf. I guess it is some completely different compiler. Even if it is what you intend to use, this other compiler should likely be ccintarm for C code compilation, as cxintarm seems to be for C++.

mity commented 5 years ago

Thanks for the PR.

I've updated CMakeFiles.txt to enforce -std=c90. Hopefully it shall help to avoid regressions with the respect to the Integrity compiler.

ec1oud commented 5 years ago

I guess it must be GHS. I know it has a reputation for being weird and anachronistic. Qt has needed other patches to support it in the past. You may be right that the C++ compiler might not be the best choice for md4c; but Qt is mostly C++ after all. The build seems to be working now anyway.