[llvmlinux] Linux-v3.10 is bootable here

Sedat Dilek sedat.dilek at gmail.com
Fri Jul 12 12:08:25 UTC 2013


On Fri, Jul 12, 2013 at 8:38 AM, Jan-Simon Möller <dl9pf at gmx.de> wrote:
[...]
> The cc-options look good and we can add those to the original patches.
>

First of all, Sam Ravnborg answered my questions to "$(call cc-option)
in combination with KBUILD_*FLAGS" in [1].
This is worth reading.

Beyond the cc-option handling, some of the x86-boot and x86-realmode
can be simplified.

[ x86-boot ]
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -53,10 +53,13 @@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE

 # How to compile the 16-bit code.  Note we always compile for -march=i386,
 # that way we can complain to the user if the CPU is insufficient.
+# NOTE: The 16-bit code is always compiled for -march=i586 with llvmlinux.
 KBUILD_CFLAGS  := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
                   -DDISABLE_BRANCH_PROFILING \
-                  -Wall -Wstrict-prototypes \
-                  -march=i386 -mregparm=3 \
+                   -Wall -Wextra -Wstrict-prototypes \
+                  -Wno-unused-value -Wno-unused-parameter \
+                  -march=i586 -mregparm=3 -mno-sse \
+                   $(call cc-option, -no-integrated-as) \
                   -include $(srctree)/$(src)/code16gcc.h \
                   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
                   $(call cc-option, -ffreestanding) \

[ x86-realmode ]
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -66,17 +66,19 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE

 # How to compile the 16-bit code.  Note we always compile for -march=i386,
 # that way we can complain to the user if the CPU is insufficient.
+# NOTE: The 16-bit code is always compiled for -march=i586 with llvmlinux.
 KBUILD_CFLAGS  := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
                   -I$(srctree)/arch/x86/boot \
                   -DDISABLE_BRANCH_PROFILING \
                   -Wall -Wstrict-prototypes \
-                  -march=i386 -mregparm=3 \
+                  -march=i586 -mregparm=3 \
                   -include $(srctree)/$(src)/../../boot/code16gcc.h \
                   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
                   $(call cc-option, -ffreestanding) \
                   $(call cc-option, -fno-toplevel-reorder,\
                        $(call cc-option, -fno-unit-at-a-time)) \
                   $(call cc-option, -fno-stack-protector) \
-                  $(call cc-option, -mpreferred-stack-boundary=2)
+                  $(call cc-option, -mpreferred-stack-boundary=2) \
+                  $(call cc-option, -no-integrated-as)
 KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
 GCOV_PROFILE := n

I am not sure why pageexec (PaX team) has chosen -march=i586.
Might be i586 is the minimum for x86-32bit for llvm/clang?
Please, also fold any comments in this direction:

# NOTE: The 16-bit code is always compiled for -march=i586 with llvmlinux.

x86-kconfig can be done more elegant:

[ x86-kconfig ]
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -56,7 +56,7 @@ config X86
        select HAVE_ARCH_KGDB
        select HAVE_ARCH_TRACEHOOK
        select HAVE_GENERIC_DMA_COHERENT if X86_32
-       select HAVE_EFFICIENT_UNALIGNED_ACCESS
+       select HAVE_EFFICIENT_UNALIGNED_ACCESS if BROKEN
        select USER_STACKTRACE_SUPPORT
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_DMA_API_DEBUG
@@ -243,6 +243,7 @@ config X86_32_LAZY_GS

 config ARCH_HWEIGHT_CFLAGS
        string
+       depends on BROKEN
        default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
        default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx
-fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10
-fcall-saved-r11" if X86_64

Last but not least: If patches are very "llvmlinux-specific" they
should be embedded like this (see some arm-patches which differ from
x86_64):

[ kbuild/kconfig ]

ifeq ($(COMPILER),clang)
...
else # GCC and compatible compilers #
...
endif # clang #


[ C-files / Header-files ]

#ifdef __clang__
...
#else (or #elif) /* GCC and compatible compilers */
...
#endif /* ifdef __clang__ */



Regards,
- Sedat -

[1] http://marc.info/?t=137303868500003&r=1&w=2


More information about the LLVMLinux mailing list