Skip to content

Commit

Permalink
ARM: force on +vfp2 (ref #11817, ref #10602)
Browse files Browse the repository at this point in the history
this seems likely to be a better default for the majority of users. plus the failure mode is a SIGILL, rather than random data getting returned from floating point computations
  • Loading branch information
vtjnash committed Jul 8, 2015
1 parent 6cc4c3c commit 378ab7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 7 additions & 4 deletions README.arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ If you run into issues building LLVM, see these notes:

# Raspberry Pi

The Raspberry Pi ARM CPU is not correctly detected by LLVM. Before
starting the build, `export JULIA_CPU_ARCH=arm1176jzf-s`. This tells
LLVM that the CPU has VFP support. See the discussion in
[#10917](https://github.com/JuliaLang/julia/issues/10917).
The Raspberry Pi ARM CPU type is not detected by LLVM.
Before starting the build, it is recommented to add `export JULIA_CPU_ARCH=arm1176jzf-s`
to your Make.user file to tune the generated code for your CPU architecture.

# Raspberry Pi 2

Expand All @@ -73,6 +72,10 @@ In the case of Raspberry Pi 2, download LLVM binaries from the LLVM website, sin
override USE_SYSTEM_LLVM=1
```

# SIGILL during sysimg.o creation

Its likely that your cpu does not support VFP. File an issue on the Julia issue tracker with the contents of /proc/cpuinfo.


# Chromebook

Expand Down
16 changes: 11 additions & 5 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5604,13 +5604,16 @@ extern "C" void jl_init_codegen(void)
jl_mcjmm = new SectionMemoryManager();
#endif
const char *mattr[] = {
#if defined(_CPU_X86_64_) || defined(_CPU_X86_)
#ifndef USE_MCJIT
// Temporarily disable Haswell BMI2 features due to LLVM bug.
"-bmi2", "-avx2",
#endif
#ifdef V128_BUG
"-avx",
#endif
#endif
"", // padding to make sure this isn't an empty array (ref #11817)
};
SmallVector<std::string, 4> MAttrs(mattr, mattr+sizeof(mattr)/sizeof(mattr[0]));
#ifdef LLVM36
Expand Down Expand Up @@ -5640,14 +5643,17 @@ extern "C" void jl_init_codegen(void)
TheTriple.setEnvironment(Triple::ELF);
#endif
#endif
StringRef TheCPU = strcmp(jl_options.cpu_target,"native") ? StringRef(jl_options.cpu_target) : StringRef(sys::getHostCPUName());
if (TheCPU.empty() || TheCPU == StringRef("generic")) {
jl_printf(JL_STDERR, "warning: unable to determine host cpu name.\n");
#ifdef _CPU_ARM_
MAttrs.append(1, "+vfp2"); // the processors that don't have VFP are old and (hopefully) rare. this affects the platform calling convention.
#endif
}
TargetMachine *targetMachine = eb.selectTarget(
TheTriple,
"",
#if LLVM35
strcmp(jl_options.cpu_target,"native") ? StringRef(jl_options.cpu_target) : sys::getHostCPUName(),
#else
strcmp(jl_options.cpu_target,"native") ? jl_options.cpu_target : "",
#endif
TheCPU,
MAttrs);
jl_TargetMachine = targetMachine->getTarget().createTargetMachine(
TheTriple.getTriple(),
Expand Down

7 comments on commit 378ab7c

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broke the windows build

codegen.cpp: In function 'void jl_dump_bitcode(char*)':
codegen.cpp:422:35: error: 'globalvars' was not declared in this scope
     jl_gen_llvm_gv_array(bitcode, globalvars);
                                   ^
make[1]: *** [codegen.o] Error 1

@helgee
Copy link
Contributor

@helgee helgee commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke the Linux and OSX builds as well: https://travis-ci.org/JuliaLang/julia/builds/70015237

Linux:

codegen.cpp:422:35: error: ‘globalvars’ was not declared in this scope

OSX:

codegen.cpp:422:35: error: use of undeclared identifier 'globalvars'
    jl_gen_llvm_gv_array(bitcode, globalvars);

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this commit, was 050eedb, but this was the only push.

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

918ee65 fixes the build failure, though there are still warnings not a recognized processor for this target (ignoring processor)

@vtjnash
Copy link
Member Author

@vtjnash vtjnash commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried to move something out of argument position, but the C++ gc semantics for it changed between llvm3.3 and llvm3.5. i'll fix.

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall some things either are StringRefs that weren't before, or the other way around

@vtjnash
Copy link
Member Author

@vtjnash vtjnash commented on 378ab7c Jul 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the argument type previously was auto-converting everything to StringRef, but the C++ finalizer behavior is different because the result type of getHostCPUName is changed between those llvm versions. fixed in 896cadf

Please sign in to comment.