[GUIDE] How to make compiling neater

Discussion in '3DS - Tutorials' started by JoostinOnline, Oct 1, 2015.

  1. JoostinOnline
    OP

    JoostinOnline Certified Crash Test Dummy

    Member
    10,918
    3,689
    Apr 2, 2011
    United States
    The Twilight Zone
    I was having trouble spotting any warnings because the output when compiling is so messy. Fixing that is pretty simple.

    Why you should do it.
    The warnings (and errors, if there were any) stick out like a sore thumb because they are so much longer. Take a look at the build output before and after following the instructions in this guide.
    Before:
    Code:
    C:\projects\3ds\Pasta-CFW\CFW_loader>make
    crypto.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/crypto.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/crypto.c -o crypto.o
    draw.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/draw.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/draw.c -o draw.o
    fs.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/fs.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c -o fs.o
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'DecryptPartition':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:95:9: warning: unused variable 'bytesWritten' [-Wunused-variable]
      size_t bytesWritten;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'InitializeNandCrypto':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:118:8: warning: unused variable 'listSystem' [-Wunused-variable]
      char* listSystem[] = { "4.x", "6.x", "7.x", "9.x" };
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:151:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:164:2: warning: implicit declaration of function 'sdmmc_nand_readsectors' [-Wimplicit-function-declaration]
      sdmmc_nand_readsectors(sector_no + partition / 0x200, numsectors, out);
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:172:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:193:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:205:2: warning: implicit declaration of function 'sdmmc_sdcard_readsectors' [-Wimplicit-function-declaration]
      sdmmc_sdcard_readsectors(sector_no + partition / 0x200, numsectors, out);
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:213:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:226:2: warning: implicit declaration of function 'sdmmc_sdcard_writesectors' [-Wimplicit-function-declaration]
      sdmmc_sdcard_writesectors(sector_no + partition / 0x200, numsectors, out); //Stubbed, i don't wanna risk
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:166:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:187:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:207:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:227:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    hid.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/hid.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/hid.c -o hid.o
    i2c.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/i2c.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/i2c.c -o i2c.o
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/i2c.c:6:43: warning: no semicolon at end of struct or union
    static const struct { u8 bus_id, reg_addr } dev_data[] = {
      ^
    main.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/main.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/main.c -o main.o
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/main.c: In function 'CFW_NandDumper':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/main.c:299:23: warning: initialization makes pointer from integer without a cast
      unsigned char* buf = 0x21000000;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/main.c:319:5: warning: implicit declaration of function 'sdmmc_nand_readsectors' [-Wimplicit-function-declaration]
      sdmmc_nand_readsectors(count*nsectors, nsectors, buf);
      ^
    platform.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/platform.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/platform.c -o platform.o
    diskio.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/diskio.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs/diskio.c -o diskio.o
    ff.c
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/ff.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=c99 -mthumb -mthumb-interwork -I/c/projects/3ds/Pasta-CFW/CFW_loader/include -I/c/projects/3ds/Pasta-CFW/CFW_loader/source -I/c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs  -I/c/projects/3ds/Pasta-CFW/CFW_loader/build -DARM9 -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/fatfs/ff.c -o ff.o
    delay.s
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/delay.d -x assembler-with-cpp -g -mthumb -mthumb-interwork -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/delay.s -o delay.o
    start.s
    arm-none-eabi-gcc -MMD -MP -MF /c/projects/3ds/Pasta-CFW/CFW_loader/build/start.d -x assembler-with-cpp -g -mthumb -mthumb-interwork -c /c/projects/3ds/Pasta-CFW/CFW_loader/source/start.s -o start.o
    linking CFW_loader.elf
    built ... CFW_loader.bin
    cp /c/projects/3ds/Pasta-CFW/CFW_loader/CFW_loader.bin loader.bin
    cp /c/projects/3ds/Pasta-CFW/CFW_loader/CFW_loader.elf loader.elf
    
    After:
    Code:
    C:\projects\3ds\Pasta-CFW\CFW_loader>make
    crypto.c
    draw.c
    fs.c
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'DecryptPartition':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:95:9: warning: unused variable 'bytesWritten' [-Wunused-variable]
      size_t bytesWritten;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'InitializeNandCrypto':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:118:8: warning: unused variable 'listSystem' [-Wunused-variable]
      char* listSystem[] = { "4.x", "6.x", "7.x", "9.x" };
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:151:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:164:2: warning: implicit declaration of function 'sdmmc_nand_readsectors' [-Wimplicit-function-declaration]
      sdmmc_nand_readsectors(sector_no + partition / 0x200, numsectors, out);
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:172:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:193:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:205:2: warning: implicit declaration of function 'sdmmc_sdcard_readsectors' [-Wimplicit-function-declaration]
      sdmmc_sdcard_readsectors(sector_no + partition / 0x200, numsectors, out);
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:213:11: warning: assignment from incompatible pointer type
      info.ctr = &myCtr; info.buffer = out; info.size = numsectors * 0x200; info.keyY = NULL;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:226:2: warning: implicit declaration of function 'sdmmc_sdcard_writesectors' [-Wimplicit-function-declaration]
      sdmmc_sdcard_writesectors(sector_no + partition / 0x200, numsectors, out); //Stubbed, i don't wanna risk
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:166:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'nand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:187:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_readsectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:207:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c: In function 'emunand_writesectors':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/fs.c:227:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    hid.c
    i2c.c
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/i2c.c:6:43: warning: no semicolon at end of struct or union
    static const struct { u8 bus_id, reg_addr } dev_data[] = {
      ^
    main.c
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/main.c: In function 'CFW_NandDumper':
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/main.c:299:23: warning: initialization makes pointer from integer without a cast
      unsigned char* buf = 0x21000000;
      ^
    c:/projects/3ds/Pasta-CFW/CFW_loader/source/main.c:319:5: warning: implicit declaration of function 'sdmmc_nand_readsectors' [-Wimplicit-function-declaration]
      sdmmc_nand_readsectors(count*nsectors, nsectors, buf);
      ^
    platform.c
    diskio.c
    ff.c
    delay.s
    start.s
    sdmc.s
    linking CFW_loader.elf
    built ... CFW_loader.bin
    cp /c/projects/3ds/Pasta-CFW/CFW_loader/CFW_loader.bin loader.bin
    cp /c/projects/3ds/Pasta-CFW/CFW_loader/CFW_loader.elf loader.elf
    
    In addition to that, it's easy to see when there are no more warnings or errors. Here's a build where all the warnings have been fixed (different project):
    Code:
    C:\projects\3ds\3ds_hb_menu>make
    app_bubble.bin
    battery_charging.bin
    battery_full.bin
    battery_low.bin
    battery_lowest.bin
    battery_mid_high.bin
    battery_mid_low.bin
    bubble.bin
    font.bin
    installerIcon.bin
    logo.bin
    regionfree.bin
    top_bar.bin
    wifi_full.bin
    wifi_none.bin
    descriptor.cpp
    tinyxml2.cpp
    background.c
    boot.c
    error.c
    filesystem.c
    font.c
    font1.c
    font2.c
    gfx.c
    main.c
    menu.c
    netloader.c
    regionfree.c
    scanner.c
    smdh.c
    statusbar.c
    text.c
    titles.c
    water.c
    linking 3ds_hb_menu.elf
    built ... 3ds_hb_menu.3dsx
    A quick scroll through the output is all it takes to see that there are no warnings or errors.

    How to do it
    Making a clean output could hardly be simpler, and it isn't project-specific. All you need to do is open "C:\devkitPro\devkitARM\base_rules" with a text editor and replace the contents with this. It has no negative effects.
     
    Last edited by JoostinOnline, Oct 2, 2015
    Clothahump, marc00077 and VegaRoXas like this.
  2. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    754
    284
    Jul 28, 2008
    United States
    How is this different than suppressing all warnings with "-w" in CFLAGS?
     
  3. JoostinOnline
    OP

    JoostinOnline Certified Crash Test Dummy

    Member
    10,918
    3,689
    Apr 2, 2011
    United States
    The Twilight Zone
    This is completely the opposite of that. It makes spotting warnings easier. It hides the pointless commands. Read the first line of "Why you should do it".
     
  4. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    754
    284
    Jul 28, 2008
    United States
    Ahh... I see that makes sense. I did not realize the clean output at the end was after the fixing the warnings. I thought it was just hiding them.
     
  5. mashers

    mashers Stubborn ape

    Member
    3,837
    5,146
    Jun 10, 2015
    Kongo Jungle
    You can achieve the same result by using "make -s". It inhibits the echoing of the individual compiler commands so you can more easily see any errors and warnings.
     
  6. JoostinOnline
    OP

    JoostinOnline Certified Crash Test Dummy

    Member
    10,918
    3,689
    Apr 2, 2011
    United States
    The Twilight Zone
    True, but it has two downsides. The first is minor, in that you have to type -s every time. The second is bigger. You will have to modify every batch/bash script by adding a -s command, and the commands used in any tools if you compile through Programmer's Notepad.

    This is a simple way that requires no changes to project files.
     
  7. mashers

    mashers Stubborn ape

    Member
    3,837
    5,146
    Jun 10, 2015
    Kongo Jungle
    Ahh I see. That is better - thanks! :)