Author Topic: Adding assembler as a compiler  (Read 9166 times)

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Adding assembler as a compiler
« on: March 20, 2014, 11:11:06 am »
Since I started to use CB now permanently as a replacement for Visual Studio, I wanted to be able to use a project wizard for creating assembly only projects (MASM in this case). As far as I understand it, currently this should be done by us ing a makefile, which I don't really want.
I looked into the CB directory and got the impression that compiler support is done via configuration XML files, so I wouldn't need to do actual code changes, is this correct? is there somehwere a detailed documentation on how a compiler is set up, so I don't have to figure everything out on my own? :)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11821
    • Travis build status
Re: Adding assembler as a compiler
« Reply #1 on: March 20, 2014, 07:41:50 pm »
Read the source or the xml files for the other compilers.
Unfortunately there are no docs for this feature yet.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Adding assembler as a compiler
« Reply #2 on: March 20, 2014, 07:49:54 pm »
I already managed to setup the files and project wizard, as well as a compiler entry. I simply used the existing XML files as a templated and changed them accordingly.
What I did not figure out yet though is, how to get rid of the common compiler switches which are located in: CB\share\CodeBlocks\compilers\options_common_warnings.xml

Is this somewhere included hardcoded? I haven't seen any file that includes this so I haven't found any way to get rid of this yet. Which means that the switches for the assembler are currently mixed with the generic C switches.

At the moment I don't see how I can override those or get rid of them entirely.
« Last Edit: March 20, 2014, 07:51:34 pm by sparhawk »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11821
    • Travis build status
Re: Adding assembler as a compiler
« Reply #3 on: March 20, 2014, 08:16:27 pm »
There is an include tag. Search for common_warnings or just warnings.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Adding assembler as a compiler
« Reply #4 on: March 20, 2014, 11:36:00 pm »
Are the compiler file (compiler_*.xml) and compiler options file (options_*.xml) what you are looking for?  (They *should* contain a description all available features... I am not completely certain if something was missed, though.)

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Adding assembler as a compiler
« Reply #5 on: March 21, 2014, 11:17:52 am »
There is an include tag. Search for common_warnings or just warnings.

Well, that's exactly what I did as my first approach and I was surprised that I didn't find anything including it. I haven't tried with just "warnings" so I will do that as well.

Are the compiler file (compiler_*.xml) and compiler options file (options_*.xml) what you are looking for?  (They *should* contain a description all available features... I am not completely certain if something was missed, though.)

Of course those were the first files I looked into, but I don't really see a complete documentation (didn't know about the wiki so thanks fo rthat pointer). I just went by looking at the different examples. Seems to work well enough, but some thigns I don't understand. For example that exec tag is unclear to me. I have an idea what it probably does, but not exactly.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6548
    • My Best Post
Re: Adding assembler as a compiler
« Reply #6 on: March 21, 2014, 08:05:13 pm »
Try looking at this file "compileroptionsdlg.cpp"; it might be what you want.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6548
    • My Best Post
Re: Adding assembler as a compiler
« Reply #7 on: March 22, 2014, 04:28:27 pm »
I already managed to setup the files and project wizard, as well as a compiler entry. I simply used the existing XML files as a templated and changed them accordingly.
What I did not figure out yet though is, how to get rid of the common compiler switches which are located in: CB\share\CodeBlocks\compilers\options_common_warnings.xml

Is this somewhere included hardcoded? I haven't seen any file that includes this so I haven't found any way to get rid of this yet. Which means that the switches for the assembler are currently mixed with the generic C switches.

At the moment I don't see how I can override those or get rid of them entirely.

If you have NOT got rid of the C/C++ options post your XML file.

I just tried making a custom compiler with no options and it seems to have worked; but, I did create cpp and h files to do it.

FYI:

The lines below include the file options_common_cmds.xml, options_common_re.xml, and options_common_sort.xml

Code: [Select]
    <Common name="cmds"/>

    <Common name="re"/>

    <Common name="sort"/>

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Adding assembler as a compiler
« Reply #8 on: March 22, 2014, 05:03:43 pm »
I just tried making a custom compiler with no options and it seems to have worked; but, I did create cpp and h files to do it.

Not sure what you mean by that. Do you mean you modified it in the code?

Quote
The lines below include the file options_common_cmds.xml, options_common_re.xml, and options_common_sort.xml

Code: [Select]
    <Common name="cmds"/>

    <Common name="re"/>

    <Common name="sort"/>

Tim S.


Thanks! That was exactly the problem. :) Removing those, got rid of the unwanted options. :)

So now I have to figure out where those include paths and librarries come from. They are from the sample where I took it, from so I have to figure out how to get rid of them.

I can already setup a project now and assemble it but not link it currently. :)

If there is interest for this, I can contribute the files that I created to CB.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6548
    • My Best Post
Re: Adding assembler as a compiler
« Reply #9 on: March 22, 2014, 05:08:18 pm »
I just tried making a custom compiler with no options and it seems to have worked; but, I did create cpp and h files to do it.

Not sure what you mean by that. Do you mean you modified it in the code?


Yes, I modified the source code; which included adding two files.
Therefore, the source code needed recompiled.
I was thinking that was needed to get rid of the options; but, it did NOT seem to be true.

Tim S.

« Last Edit: March 22, 2014, 05:10:31 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Adding assembler as a compiler
« Reply #10 on: March 22, 2014, 06:23:39 pm »
I was thinking that was needed to get rid of the options; but, it did NOT seem to be true.

Yes, for the options it is not needed. Do you know where the includes are setup? I still have AVR paths in my commandline, where I don't know where they come from. Linker and assembler.

Code: [Select]
ml.exe /IC:\MASM32\avr\include
LINK.exe /LC:\MASM32\avr\lib


Offline stahta01

  • Lives here!
  • ****
  • Posts: 6548
    • My Best Post
Re: Adding assembler as a compiler
« Reply #11 on: March 22, 2014, 06:40:41 pm »
Could be XML file; without knowing which XML you copied and how you modified it I have no way to tell.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Adding assembler as a compiler
« Reply #12 on: March 22, 2014, 06:43:47 pm »
I used the avr-gcc file. I removed all references but I don't see where this comes from.

Compiler
Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_compiler>
<CodeBlocks_compiler name="MASM 32/64"
                     id="masm"
                     weight="60">
    <Path type="master">
        <Search envVar="PATH"
                for="ml.exe"/>
        <if platform="windows">
            <Search path="C:\MASM32"/>
            <Fallback path="C:\MASM32"/>
        </if>
        <if platform="windows">
            <Search path="D:\MASM32"/>
            <Fallback path="D:\MASM32"/>
        </if>
    </Path>
<Path type="include">
<Add><master/>\include</Add>
</Path>
<Path type="lib">
<Add><master/>\lib</Add>
</Path>
</CodeBlocks_compiler>

Options
Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_compiler_options>
<CodeBlocks_compiler_options>
    <if platform="windows">
        <Program name="ASM"       value="ml.exe"/>
        <Program name="LD"        value="LINK.exe"/>
        <Program name="DBGconfig" value="gdb_debugger:Default"/>
        <Program name="LIB"       value="LINK.exe"/>
        <Program name="WINDRES"   value="windres.exe"/>
        <Program name="MAKE"      value="mingw32-make.exe"/>
    </if>

    <Switch name="includeDirs"             value="/I"/>
    <Switch name="libDirs"                 value="/L"/>
    <Switch name="linkLibs"                value="-l"/>
    <Switch name="defines"                 value="/D"/>
    <Switch name="genericSwitch"           value="/"/>
    <Switch name="objectExtension"         value="obj"/>
    <Switch name="needDependencies"        value="true"/>
    <Switch name="forceCompilerUseQuotes"  value="false"/>
    <Switch name="forceLinkerUseQuotes"    value="false"/>
    <Switch name="logging"                 value="default"/>
    <Switch name="libPrefix"               value="lib"/>
    <Switch name="libExtension"            value="a"/>
    <Switch name="linkerNeedsLibPrefix"    value="false"/>
    <Switch name="linkerNeedsLibExtension" value="false"/>
    <Switch name="supportsPCH"             value="true"/>
    <Switch name="PCHExtension"            value="gch"/>
    <Switch name="UseFullSourcePaths"      value="true"/>

    <!-- Summary of MASM options: -->

    <Option name="Produce debugging symbols"
            option="/MZ"
            category="Debugging"
            checkAgainst=""
            checkMessage="You have optimizations enabled. This is Not A Good Thing(tm) when producing debugging symbols..."
            supersedes=""/>
    <Option name="Generate COFF format (not available for x64) required for Win32"
            option="/coff"
            category="Debugging"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Generates line-number information in object file."
            option="/Zd"
            category="Debugging"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Generates CodeView information in object file."
            option="/Zi"
            category="Debugging"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>

    <!-- warnings -->
    <Option name="Warning Level 0 and report an error if warnings exist"
            option="/w"
            category="Warning level"
            checkAgainst=""
            checkMessage=""
exclusive="true"
            supersedes=""/>
    <Option name="Warning Level 0"
            option="/W 0"
            category="Warning level"
            checkAgainst=""
            checkMessage=""
exclusive="true"
            supersedes=""/>
    <Option name="Warning Level 1"
            option="/W 1"
            category="Warning level"
            checkAgainst=""
            checkMessage=""
exclusive="true"
            supersedes=""/>
    <Option name="Warning Level 2"
            option="/W 2"
            category="Warning level"
            checkAgainst=""
            checkMessage=""
exclusive="true"
            supersedes=""/>
    <Option name="Warning Level 3"
            option="/W 3"
            category="Warning level"
            checkAgainst=""
            checkMessage=""
exclusive="true"
            supersedes=""/>
    <Option name="Warning Level 4"
            option="/W 4"
            category="Warning level"
            checkAgainst=""
            checkMessage=""
exclusive="true"
            supersedes=""/>

    <!-- symbols -->

    <Option name="Preserves case of all user identifiers."
            option="/Cp"
            category="Symbols"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Maps all identifiers to upper case (default)."
            option="/Cu"
            category="Symbols"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Preserves case in public and extern symbols."
            option="/Cx"
            category="Symbols"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Makes all symbols public."
            option="/Zf"
            category="Symbols"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>

    <!-- Listing -->
    <Option name="Turns on listing of all available information."
            option="/Sa"
            category="Listing"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Adds first-pass listing to listing file."
            option="/Sf"
            category="Listing"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Turns off symbol table when producing a listing."
            option="/Sn"
            category="Listing"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Turns on false conditionals in listing."
            option="/Sx"
            category="Listing"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Generates a preprocessed source listing (sent to STDOUT). See /Sf."
            option="/EP"
            category="Listing"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>

    <!-- Language -->
    <Option name="Specifies use of FORTRAN- or Pascal-style function calling and naming conventions. Same as OPTION LANGUAGE:PASCAL."
            option="/Gc"
            category="Language"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Specifies use of C-style function calling and naming conventions. Same as OPTION LANGUAGE:C."
            option="/Gd"
            category="Language"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Specifies use of __stdcall function calling and naming conventions. Same as OPTION LANGUAGE:STCALL."
            option="/GZ"
            category="Language"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>

    <!-- Misc -->
    <Option name="Generates emulator fix-ups for floating-point arithmetic (mixed language only)."
            option="/FPi"
            category="Misc"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Marks the object as either containing no exception handlers or containing exception handlers that are all declared with .SAFESEH."
            option="/safeseh"
            category="Misc"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Ignore INCLUDE environment path."
            option="/X"
            category="Misc"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>
    <Option name="Enables M510 option for maximum compatibility with MASM 5.1."
            option="/Zm"
            category="Misc"
            checkAgainst=""
            checkMessage=""
            supersedes=""/>

    <Command name="CompileObject"
             value="$compiler /nologo $options $includes /Fo $object /c $file "/>
    <Command name="CompileResource"
             value="$rescomp $res_includes -fo$resource_output $file"/>
    <Command name="LinkExe"
             value="$linker /nologo /subsystem:windows $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkConsoleExe"
             value="$linker /nologo $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkDynamic"
             value="$linker /dll /nologo $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkStatic"
             value="$lib_linker /lib /nologo $libdirs /out:$static_output $libs $link_objects $link_resobjects $link_options"/>
    <Command name="LinkNative"
             value="$linker /nologo /subsystem:native $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"/>
</CodeBlocks_compiler_options>

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6548
    • My Best Post
Re: Adding assembler as a compiler
« Reply #13 on: March 22, 2014, 06:47:52 pm »
Here's the code that likely does it.
Code: [Select]
    </Path>
<Path type="include">
<Add><master/>\include</Add>
</Path>
<Path type="lib">
<Add><master/>\lib</Add>
</Path>
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sparhawk

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Adding assembler as a compiler
« Reply #14 on: March 22, 2014, 06:53:56 pm »
Ah, I found it. Apparently I set it manually in the global compiler settings and forgot about it. :o

So now it works. :D Almost. :o

Can I also set additional options in the wizard? I would like to to automatically switch on COFF format, and debugging in the Debug build, as well as adding kernel32.lib as default library.