[apparmor] [patch} parser: convert array into unordered map (was Re: [Branch ~apparmor-dev/apparmor/master] Rev 2193: Convert the parser to C++)

Seth Arnold seth.arnold at canonical.com
Mon Nov 18 19:48:58 UTC 2013


On Sat, Nov 16, 2013 at 11:59:03PM -0800, Steve Beattie wrote:
> On Fri, Nov 08, 2013 at 02:59:23PM -0600, Jamie Strandboge wrote:
> > I just now noticed that the daily builds using gcc/g++ 4.6 started failing,
> > presumably after this patches series:
> > https://launchpadlibrarian.net/151700403/buildlog_ubuntu-precise-i386.apparmor_2.7.104%2B2200%2B12~ubuntu12.04.1_FAILEDTOBUILD.txt.gz
> 
> Yes, the conversion to C++ did break with g++ 4.6 due to the designated
> array initializer used for the state_names array in parser_lex.l. 
> > gcc/g++ 4.7 were fine with this patchset:
> > https://launchpadlibrarian.net/155989184/buildlog_ubuntu-quantal-i386.apparmor_2.7.104%2B2249%2B12~ubuntu12.10.1_UPLOADING.txt.gz
> > 
> > The question becomes, do we care about gcc/g++ 4.6? If so, we should fix this
> > (it seems we might be able to fiddle with build flags to make it work, but I'll
> > let others dive in). If not, we should update our builds to fail with 4.6.
> 
> Unfortunately, it's not as simple as fiddling with make flags, it still
> fails to compile with g++ 4.6 even when the -std=gnu++0x flag is given.

Aww, that's too bad. I still don't know how C++11 was released without
designated array initalization (and named initializers in structs),
but we ought to keep gcc 4.6 compatibility and deal with it. :(

> That said, I think continuing to support g++ 4.6 is important, given
> it's the compiler version in Ubuntu 12.04 LTS (aka precise). So here
> is a patch that converts the problematic array definition into a C++
> unordered_map type. Using this depends on using the c++0x (aka c++11)
> standard, and as we have gnuisms elsewhere (using the typeof builtin),
> the patch also adds/converts to using -std=gnu++c0x in the build
> rules (which conveniently eliminates some other warnings we had due
> to other c++11-isms).

Very nice. I certainly don't mind using gnuisms, compiling on a platform
where clang is the compiler of choice seems unlikely for many reasons.

> Signed-off-by: Steve Beattie <steve at nxnw.org>

Acked-By: Seth Arnold <seth.arnold at canonical.com>

> -#define PDEBUG(fmt, args...) printf("Lexer (Line %d) (state %s): " fmt, current_lineno, state_names[YY_START], ## args)
> +#define PDEBUG(fmt, args...) printf("Lexer (Line %d) (state %s): " fmt, current_lineno, state_names[YY_START].c_str(), ## args)


In time we should probably migrate these to:

cout << "Lexer (Line " << current_lineno << ") (state " << state_names[YY_START] << "): << ...

But there's no need to hold up this patch now for that trasition.

Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20131118/8f9cb7b1/attachment.pgp>


More information about the AppArmor mailing list