kphp icon indicating copy to clipboard operation
kphp copied to clipboard

Enable build for other architecture without patching

Open comm644 opened this issue 1 year ago • 0 comments

Problem: kphp2cpp configured only with -march sandybridge, but application binary can be executed in KVM.

Solution: kphp2cpp must compile resulting binary with same flags as compiled or configured by cmake flags, or must don't set flags for using user-defined compiler flags.

I found two places: cmake/init-compilation-flags.cmake

if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
-    add_compile_options(-march=sandybridge -fno-common)
+    add_compile_options(-march=core2 -mpclmul -msse2 -fno-common)
     add_link_options(-fno-common)

At here option must be configured by command line arguments.

compiler/compiler-settings.cpp

--- a/compiler/compiler-settings.cpp
+++ b/compiler/compiler-settings.cpp
@@ -280,7 +280,7 @@ void CompilerSettings::init() {
   ss << " -Wall -fwrapv -Wno-parentheses -Wno-trigraphs";
   ss << " -fno-strict-aliasing -fno-omit-frame-pointer";
 #ifdef __x86_64__
-  ss << " -march=sandybridge";
 #endif
   if (!no_pch.get()) {

at here option must be removed or reused from cmake options.

comm644 avatar Mar 11 '23 00:03 comm644