diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java
index 8ddb29cdc5c..8992d03fab5 100644
--- a/arduino-core/src/processing/app/BaseNoGui.java
+++ b/arduino-core/src/processing/app/BaseNoGui.java
@@ -65,7 +65,7 @@ public class BaseNoGui {
   }
 
   private static DiscoveryManager discoveryManager = new DiscoveryManager();
-  
+
   // these are static because they're used by Sketch
   static private File examplesFolder;
   static private File toolsFolder;
@@ -129,7 +129,8 @@ static public File getBuildFolder(SketchData data) throws IOException {
       buildFolder = absoluteFile(PreferencesData.get("build.path"));
       Files.createDirectories(buildFolder.toPath());
     } else {
-      buildFolder = FileUtils.createTempFolder("build", DigestUtils.md5Hex(data.getMainFilePath()) + ".tmp");
+      PreferencesMap targetBoardPrefs = getTargetBoard().getPreferences();
+      buildFolder = FileUtils.createTempFolder("build", DigestUtils.md5Hex(data.getMainFilePath() + targetBoardPrefs.get("build.arch") + targetBoardPrefs.get("build.board")) + ".tmp");
       DeleteFilesOnShutdown.add(buildFolder);
     }
     return buildFolder;
@@ -140,7 +141,7 @@ static public PreferencesMap getBoardPreferences() {
     if (board == null)
       return null;
     String boardId = board.getId();
-    
+
     PreferencesMap prefs = new PreferencesMap(board.getPreferences());
 
     String extendedName = prefs.get("name");
@@ -399,7 +400,7 @@ static public void init(String[] args) throws Exception {
     parser.parseArgumentsPhase1();
 
     String sketchbookPath = getSketchbookPath();
-  
+
     // If no path is set, get the default sketchbook folder for this platform
     if (sketchbookPath == null) {
       if (BaseNoGui.getPortableFolder() != null)
@@ -421,7 +422,7 @@ static public void init(String[] args) throws Exception {
     for (String path: parser.getFilenames()) {
       // Correctly resolve relative paths
       File file = absoluteFile(path);
-  
+
       // Fix a problem with systems that use a non-ASCII languages. Paths are
       // being passed in with 8.3 syntax, which makes the sketch loader code
       // unhappy, since the sketch folder naming doesn't match up correctly.
@@ -445,7 +446,7 @@ static public void init(String[] args) throws Exception {
         showError(null, mess, 2);
       }
     }
-  
+
     // Save the preferences. For GUI mode, this happens in the quit
     // handler, but for other modes we should also make sure to save
     // them.
@@ -771,7 +772,7 @@ static public void main(String args[]) throws Exception {
     getPlatform().init();
 
     initPortableFolder();
-    
+
     initParameters(args);
 
     checkInstallationFolder();