#91 Patch to allow Exult to compile under 'clang' complier

closed-accepted
None
5
2011-01-08
2011-01-06
No

I tried compiling Exult with the clang compiler (http://clang.llvm.org/) which is a bit stricter in regards to C++ than GCC. Most everything built, but it had a few issues which I was able to solve by reading Clang Language Compatibility documentation (http://clang.llvm.org/compatibility.html) specifically the the "Unqualified lookup in templates" and "Unqualified lookup into dependent bases of class templates" sections.

Everything seems to build using this patch, and Exult seems to run fine (so far).

Discussion

  • Jason C. Penney

    Jason C. Penney - 2011-01-06

    small patch to allow use of clang compiler

     
    Attachments
  • Malignant Manor

    Malignant Manor - 2011-01-07

    This patch has been added with a modification to one line. Does the latest SVN compile?

     
  • Malignant Manor

    Malignant Manor - 2011-01-07
    • assigned_to: nobody --> malignantmanor
    • status: open --> pending-accepted
     
  • Jason C. Penney

    Jason C. Penney - 2011-01-07

    This now compiles, thanks.

    I should note that I haven't tried building with Exult Studio enabled under clang yet. I'm building under clang 2.8 x86_64-apple-darwin10.

    I went through all the warnings produced (see below).

    I'm pretty sure the one from keys.cc is a bug. My understanding is that
    a.action->desc == "Create last shape"
    (since a.action->desc is a C 'char *', not a C++ 'string') will check if a.action->desc (the pointer) points to the same memory as the literal "Create last shape" (which it won't). I believe the correct code would be:
    strcmp(a.action->desc, "Create last shape") == 0
    This would require including string.h

    The one in ucstmt.cc looks like an actual bug since the body of the block after the if is going to run every time regardless of the if.

    (i'm not sure how to make the sf.net tracker display this preformatted, so it's possible this will look a bit funky)

    <pre>
    zip.c:171:13: warning: unused function 'free_linkedlist' [-Wunused-function]
    static void free_linkedlist(linkedlist_data* ll)
    ^

    zip.c:230:12: warning: unused function 'write_datablock' [-Wunused-function]
    static int write_datablock(FILE* fout, linkedlist_data* ll)
    ^

    weaponinf.cc:167:2: warning: expression result unused [-Wunused-value]
    *ptr++; // Skip (0).
    ^~~~~~

    ucdisasm.cc:108:24: warning: conversion specifies type 'unsigned short' but the
    argument has type 'int' [-Wformat]
    std::printf("\t%04hXH\t\t; %d", immed32...
    ~~~~^ ~~~~~~~
    %04d

    ucstmt.cc:412:18: warning: if statement has empty body [-Wempty-body]
    if (!array_size);
    ^

    keys.cc:684:22: warning: result of comparison against a string literal is
    unspecified (use strncmp instead)
    if (a.action->desc == "Create last shape" && a.params[0] == -1)
    ^ ~~~~~~~~~~~~~~~~~~~
    </pre>

     
  • Jason C. Penney

    Jason C. Penney - 2011-01-07
    • status: pending-accepted --> open-accepted
     
  • Jason C. Penney

    Jason C. Penney - 2011-01-07

    Warnings from successful clang build (to preserve formatting)

     
    Attachments
  • Malignant Manor

    Malignant Manor - 2011-01-07

    Thanks, I fixed the ucstmt.cc bug and the keys.cc warning. It would be nice to know if everything compiles in Clang. Let me know if you are going to test it or not.

     
  • Jason C. Penney

    Jason C. Penney - 2011-01-07

    Glad to help. By "everything" do you mean "with Exult Studio"?

    I have GTK bound to Quartz (OS X native GUI) and not X11, so I'm able to make a not-quite-usable Exult Studio build with a minor change under GCC (I can launch the exult-studio comes up fine, but launching Exult itself crashes). But I can rerun that build using clang (which will at least ensure it builds) and let you know.

     
  • Malignant Manor

    Malignant Manor - 2011-01-07

    >>> Glad to help. By "everything" do you mean "with Exult Studio"?

    Yes, and tools if they weren't already build.

     
  • Jason C. Penney

    Jason C. Penney - 2011-01-07

    Everything seems to be building all right.

    $ CC=clang CXX=clang++ \ LDFLAGS="-L/opt/local/lib" \ CPPFLAGS="-I/opt/local/include -I/usr/include" \ ./configure \ --enable-mt32emu \ --enable-exult-studio-support \ --enable-macosx-studio-support \ --enable-exult-studio \
    --enable-opengl \ --enable-compiler

    [...]

    Exult v1.5.0svn

    SDL ....................... : 1.2.14
    GLIB ...................... : 2.26.1
    GTK+ ...................... : 2.22.1
    libGlade .................. : 2.6.4
    libGnomeui................. : 2.24.4

    Build tools................ : yes
    Build usecode compiler..... : yes
    Build Exult mods........... : no
    Build Exult Studio......... : yes
    Exult Studio support....... : yes

    Behavior seems the same as the GCC build I made the same way.

    Two new warnings, but I don't think they are of immediate concern. I'll attach them.

     
  • Jason C. Penney

    Jason C. Penney - 2011-01-07

    Warnings from clang build (see 2011-01-07 21:35:27 GMT comment)

     
    Attachments
  • Malignant Manor

    Malignant Manor - 2011-01-08

    Thanks again for your help, I'm closing the tracker now.

     
  • Malignant Manor

    Malignant Manor - 2011-01-08
    • status: open-accepted --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks