ton-blockchain / ton

Main TON monorepo
Other
2.89k stars 851 forks source link

[Feature Request] Add build flag/config to disable compiler optimizations #181

Open bcaw opened 4 years ago

bcaw commented 4 years ago

It appears there are some default compiler optimizations set depending on the type of build you are running. It would be great to have a config or flag that we could set to disable certain compiler optimizations when building the Fift and Lite Client binaries. Could you provide this, or instructions on how to achieve the desired result using cmake?

Context: If the binaries are compiled an an hvm ec2 instance and then executed on a paravirtualized ec2 instance, it is very easy to generate SIGILL errors due to some of the vector optimizations that the compiler is doing which aren't supported on older hardware. An easy way around this is to disable the optimizations and still allow the build to happen on a newer or separate system.

ton-blockchain commented 4 years ago

-march=native is used by default. To turn this off you may use "-DTON_ARCH=" during CMake configuration.

bcaw commented 4 years ago

Thanks @ton-blockchain. Any way to disable/override vector optimizations as well?

bcaw commented 4 years ago

Hi @ton-blockchain - Specifying the architecture does't work in all cases, as even some ec2 instances with a specific architecture (e.g. sandybridge) have certain hardware features disabled that would otherwise be available to that architecture normally.

Could you advise on how we may disable all (or specific) optimizations when building via CMake?