Skip to content

Commit 1b69603

Browse files
committed
fix "fatal error: cannot execute 'cc1'" for sdcc
1 parent e5b3564 commit 1b69603

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/CodeBuilder.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,12 @@ export abstract class CodeBuilder {
470470
getOutDir: () => { return this.project.ToAbsolutePath(outDir); }
471471
}, builderOptions.options);
472472

473+
// add extra system search path
474+
if (toolchain.exportSystemSearchPath) {
475+
toolchain.exportSystemSearchPath(builderOptions.options)
476+
.forEach(p => builderOptions.sysPaths?.push(p));
477+
}
478+
473479
// handle options
474480
this.preHandleOptions(builderOptions.options);
475481

src/ToolchainManager.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ export interface IToolchian {
162162
*/
163163
migrateOptions?: (oldOptions: BuilderOptions) => void;
164164

165+
/**
166+
* 导出额外的系统搜索路径(如果有的话)
167+
*/
168+
exportSystemSearchPath?: (builderOptions: BuilderOptions) => string[];
169+
165170
newInstance(): IToolchian;
166171
}
167172

@@ -1214,6 +1219,14 @@ class GNU_SDCC_MCS51 implements IToolchian {
12141219
}
12151220
}
12161221

1222+
exportSystemSearchPath(builderOptions: BuilderOptions): string[] {
1223+
const r: string[] = [];
1224+
// to fix: sdcpp.exe: fatal error: cannot execute 'cc1': CreateProcess: No such file or directory
1225+
if (platform.osType() == 'win32')
1226+
r.push(File.ToLocalPath(NodePath.join(this.getToolchainDir().path, 'libexec', 'sdcc', 'x86_64-w64-mingw32', '12.1.0')));
1227+
return r;
1228+
}
1229+
12171230
getInternalDefines<T extends BuilderConfigData>(builderCfg: T, builderOpts: BuilderOptions): utility.CppMacroDefine[] {
12181231

12191232
const mList: utility.CppMacroDefine[] = [

0 commit comments

Comments
 (0)