Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/IceBrowserCompileServer.cpp

Issue 1696123003: Subzero: Set the correct target arch in the browser hookup. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Better bad-target error messages Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/IceTargetLowering.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceBrowserCompileServer.cpp
diff --git a/src/IceBrowserCompileServer.cpp b/src/IceBrowserCompileServer.cpp
index 469e56df6cdf6878d810e21dfd8b7752020939aa..b9903bf53b07199f55109253478eddb74de8719c 100644
--- a/src/IceBrowserCompileServer.cpp
+++ b/src/IceBrowserCompileServer.cpp
@@ -17,6 +17,13 @@
#if PNACL_BROWSER_TRANSLATOR
#include "IceBrowserCompileServer.h"
+
+// Headers which are not properly part of the SDK are included by their path in
+// the NaCl tree.
+#ifdef __pnacl__
+#include "native_client/src/untrusted/nacl/pnacl.h"
+#endif // __pnacl__
+
#include "llvm/Support/QueueStreamer.h"
#include <cstring>
@@ -116,6 +123,35 @@ void fatalErrorHandler(void *UserData, const std::string &Reason,
pthread_exit(0);
}
+/// Adapted from pnacl-llc's AddDefaultCPU() in srpc_main.cpp.
+TargetArch getTargetArch() {
+#if defined(__pnacl__)
+ switch (__builtin_nacl_target_arch()) {
John 2016/02/16 12:03:10 apparently __builtin_nacl_target_arch is deprecate
Jim Stichnoth 2016/02/16 13:52:12 Yeah, I noticed that, but I have no idea why the t
+ case PnaclTargetArchitectureX86_32:
+ case PnaclTargetArchitectureX86_32_NonSFI:
+ return Target_X8632;
+ case PnaclTargetArchitectureX86_64:
+ return Target_X8664;
+ case PnaclTargetArchitectureARM_32:
+ case PnaclTargetArchitectureARM_32_NonSFI:
+ return Target_ARM32;
+ case PnaclTargetArchitectureMips_32:
+ return Target_MIPS32;
+ default:
+ llvm::report_fatal_error("no target architecture match.");
+ }
+#elif defined(__i386__)
+ return Target_X8632;
+#elif defined(__x86_64__)
+ return Target_X8664;
+#elif defined(__arm__)
+ return Target_ARM32;
+#else
+// TODO(stichnot): Add mips.
+#error "Unknown architecture"
+#endif
+}
+
} // end of anonymous namespace
BrowserCompileServer::~BrowserCompileServer() = default;
@@ -135,8 +171,7 @@ void BrowserCompileServer::getParsedFlags(uint32_t NumThreads, int argc,
Flags.setNumTranslationThreads(NumThreads);
Flags.setUseSandboxing(true);
Flags.setOutFileType(FT_Elf);
- // TODO(jvoung): allow setting different target arches.
- Flags.setTargetArch(Target_X8632);
+ Flags.setTargetArch(getTargetArch());
ExtraFlags.setBuildOnRead(true);
ExtraFlags.setInputFileFormat(llvm::PNaClFormat);
}
« no previous file with comments | « no previous file | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698