[cfe-dev] Compiling xv6 with Clang

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Thu Nov 8 15:10:47 PST 2018


As in the code is still too large even using -Os or -Oz? (using them
together would just have one override the other, consulting the manual, it
seems -Oz is the more aggressive size-reduction mode (
https://clang.llvm.org/docs/CommandGuide/clang.html#code-generation-options
 )).

If that still doesn't produce sufficiently small code, I'm not sure what
else to try - sorry. Perhaps someone else on the mailing list does.

On Thu, Nov 8, 2018 at 3:08 PM Ahmad Nouralizadeh Khorrami <
ahmad.llvm at gmail.com> wrote:

> Hi David,
> The problem is still there. The sequence of commands to build the
> bootblock (for gcc) is as follows:
> gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb
> -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pic -O
> -nostdinc -I. -c bootmain.c
> gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb
> -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pic
> -nostdinc -I. -c bootasm.S
> ld -m    elf_i386 -N -e start -Ttext 0x7C00 -o bootblock.o bootasm.o
> bootmain.o
> objdump -S bootblock.o > bootblock.asm
> objcopy -S -O binary -j .text bootblock.o bootblock
> ./sign.pl bootblock
> There are two files (one assembly file and one C file that are linked to
> generate the boot block). Any help is appreciated.
> Regards.
>
> On Sun, 4 Nov 2018 at 19:28, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Hard to say without more info - it's possible that Clang doesn't produce
>> as compact code as GCC in some cases. You can try compiling with
>> optimization modes that prioritize code size: -Os and -Oz (one of them is
>> more agrgessive, I forget which)
>>
>> On Sun, Nov 4, 2018 at 3:30 AM Ahmad Nouralizadeh Khorrami via cfe-dev <
>> cfe-dev at lists.llvm.org> wrote:
>>
>>> Hi.
>>> I tried to compile xv6 (a 10000 line teaching operating system from
>>> MIT) with Clang instead of GCC, but it led to an error. The compiled
>>> bootblock was larger than 1 sector (i.e., 512 bytes). Should I change the
>>> compiler options? How?
>>> Thanks!
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181108/7826ddcd/attachment.html>


More information about the cfe-dev mailing list