Author Topic: Add Keil C51/CX51 compiler  (Read 43954 times)

Offline tomjnx

  • Multiple posting newcomer
  • *
  • Posts: 34
Add Keil C51/CX51 compiler
« on: May 06, 2011, 01:41:17 pm »
Keil C51/CX51 is a fairly popular commercial compiler for MCS51 microcontrollers.

Two flavours are available; AFAIK the difference of CX51 versus C51 is:
- different object file format (especially debug information)
- linker (whole program) optimizations
- even more $$$

Compared to pretty much all other compilers, they have a very peculiar command line syntax:
- include files must be specified as INCDIR(inc1;inc2) instead of -Iinc1 -Iinc2
- there is no way to specify library directories
- objects (and libraries) must be given in the command line as obj1.obj,obj2.obj,lib1.lib,lib2.lib (i.e. commas and no -llib)
- return value can be zero (no warnings/errors) and one (warnings present/no errors) for a successful compilation

I extended the compiler framework as follows:
- when (pathname) option strings end with "(", the pathnames are grouped together and closed with ")"
- separators are configurable
- the highest return value to be considered successful is configurable
- there are new "variables" to handle the object case
- in the absence of a switch for specifying library directories (empty string), C::B walks the library paths itself and finds the libs for the linker

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Add Keil C51/CX51 compiler
« Reply #1 on: May 06, 2011, 02:10:39 pm »
Hi,

Thank you for you contribution.
I've some remarks about the patch:
1. Generate the patch with "svn diff -x '-u -b' > name.patch", because there are many newline character changes
2. Post the patch in the project page on berlios.de, attachments in the forum are deleted, when there is no empty space on disk.
3. Is this absolutely necessary? As far as I know, there is a policy in C::B to no do anything automatically and surprise the user.
    (I've not checked the code because of 1)
- in the absence of a switch for specifying library directories (empty string), C::B walks the library paths itself and finds the libs for the linker
(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 tomjnx

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Add Keil C51/CX51 compiler
« Reply #2 on: May 06, 2011, 03:07:55 pm »
I've uploaded a whitespace change less version of the patch to berlios.

3. Is this absolutely necessary? As far as I know, there is a policy in C::B to no do anything automatically and surprise the user.
    (I've not checked the code because of 1)
- in the absence of a switch for specifying library directories (empty string), C::B walks the library paths itself and finds the libs for the linker

Bad/confusing wording, sorry.

What I meant was when m_Switches.libDirs is empty, it is taken as an indication that the linker does not support library directories and C::B walks the paths for the linker.

Now libDirs is something the user cannot set AFAIK, only the developer of the compiler plugin. So there's little chance for confusing the user, only the compiler plugin developer.

This method could be a problem for DMC and DMD under windows though - they do not define libDirs. The question now is is it desirable to do the path walk in C::B for these compilers too, or not.

Tom

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Add Keil C51/CX51 compiler
« Reply #3 on: May 06, 2011, 06:05:41 pm »
Keep in mind that you should not change the behaviour of all the other compilers, because people depend on it!
Also if you can show full log from the compiler to see what is required.
(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 tomjnx

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Add Keil C51/CX51 compiler
« Reply #4 on: May 06, 2011, 10:00:26 pm »
Keep in mind that you should not change the behaviour of all the other compilers, because people depend on it!
That was an accident. I fixed this by introducing a dedicated flag to request C::B pathwalk

Also if you can show full log from the compiler to see what is required.

-------------- Clean: Debug in lcd-keil ---------------

Cleaned "lcd-keil - Debug"

-------------- Build: Debug in lcd-keil ---------------

C51.exe lcd.c OBJECT(obj\Debug\lcd.obj) WARNINGLEVEL(2) OBJECTEXTEND SMALL  DEBUG    INCDIR(C:\eda\Keil\C51\inc;"C:\Program Files\AXSEM\AXSDB\examples\libmf\include")
C51 COMPILER V8.02 - SN: XXXXX-XXXXXX
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2006
C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
BL51.exe "obj\Debug\lcd.obj,\"C:\Program Files\AXSEM\AXSDB\examples\libmf\keil\libmf.lib\"" TO bin\Debug\lcd-keil.omf DW(6) RAMSIZE(256) XDATA(0x0-0x1FFF) CODE(0x0-0xFFFF)
BL51 BANKED LINKER/LOCATER V6.00 - SN: XXXXX-XXXXXX
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2005
Program Size: data=14.0 xdata=438 code=313
LINK/LOCATE RUN COMPLETE.  0 WARNING(S),  0 ERROR(S)
Output size is 12.59 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)


chetansaundankar

  • Guest
Re: Add Keil C51/CX51 compiler
« Reply #5 on: January 25, 2012, 08:09:58 am »
I came across the patch to add support for keil compiler (cx51). I have following queries/observations regarding the same -

- Does the patch work with the latest version?
- I tried patching the latest source but got stuck at GetOrderedIncludeDirs function in /src/sdk/compilercommandgenerator.cpp file (line 741 of patch file). This is actually a file which could not be merged using TortoiseGit's TortoiseMerge tool. So I started merging manually but I couldnt understand couple of hunks after line 735 of patch file.