How to use CG with LLVM for Renesas RL78
If you are working on an existing project, using GCC RL78 and CG (Code Generator) and would like to migrate to LLVM RL78 or would like to use LLVM RL78 for a device which is supported by CG but not SC (Smart Configurator), using CG generated source files in an LLVM RL78 project is possible by following the steps below:
1. Create or Import an existing GCC RL78 project with CG support in e2 studio.
2. Create and prepare a new LLVM RL78 project:
• create a new LLVM RL78 project without SC support
• make sure to select the same RL78 device as for the GCC project
• make sure to use equivalent compiler options.
• from the <llvm_project>/generate folder, delete the following files:
- hwinit.c - interrupt_handlers.h - inthandler.c - typedefine.h - vects.c
• from the <llvm_project>/src folder delete the default <llvm_project>.c file.
OBS. For ease of use we recommend the two project are part of the same workspace.
3. Configure and generate code in the GCC project using the CG. For details on the CG usage, please see https://www.renesas.com/us/en/document/mat/code-generator-users-manual-rl78-api-reference
4. Import the generated and any custom files you may have from the GCC project into the LLVM project:
• right click on the <llvm_project>/src folder and select Import...
• select General/File System and press Next
• press Browse and nagivate to/select the <gcc_project>/src folder
• click on the Advanced>> button and check the Create links in workspace checkbox
• in the right side list select all the files, except the r_reset_program.asm and <gcc_project>.c, since for these we will be using the ones from the LLVM project
• press Finish
5. Build the LLVM project.
6. Please note that the files imported from the GCC project are linked and not copied. This results in the following behavior:
• if a file is deleted from the GCC project, by hand or by using the CG, the link to it from the LLVM project needs to be deleted manually too
• if a file is changed in the GCC or the LLVM project, the changes are reflected in both projects (if the given file was linked)
• if a new file is created in the GCC project or generated by the CG, you need to import that file manually into the LLVM project to be able to use it (see step 4.)
• when including header files, the preprocessor takes into account the physical location of the file being processed. This means that linked files from the GCC project can include header files from the same folder they reside in, but newly created files in the LLVM project can include header files from the GCC project only if in the LLVM project/Properties/Compiler/Includes list the correct GCC project folders were added.
7. Please note that CG may add one or more of the following sections to the GCC RL78 project linker script:
• .ocd_traceram, .hot_pluginram, those need to be manually added to the the LLVM RL78 linker script after .data section.
• .dtc_vectorable, .dtc_controldata_1, .dtc_controldata_2, .... ,.dtc_controldata_23, those need to be manually added to the the LLVM RL78 linker script before .stack section.