Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
Signed-off-by: leleliu008 <leleliu008@gmail.com>
  • Loading branch information
leleliu008 committed Mar 13, 2024
1 parent 48f85a7 commit 4261efa
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -6513,7 +6513,7 @@ static int try_compile(const char * compilerFilePath, const char * compilerOptio
}
}

static int check_if_compiler_support_Wno_error_unused_command_line_argument(const char * sessionDIR, const size_t sessionDIRLength, const char * compiler, const bool iscc) {
static int check_if_compiler_support_Wno_error_unused_command_line_argument(const char * sessionDIR, const size_t sessionDIRLength, const char * compiler, const bool iscc, const char * ccflags, const char * ldflags) {
size_t testCFilePathCapacity = sessionDIRLength + 10U;
char testCFilePath[testCFilePathCapacity];

Expand Down Expand Up @@ -6556,7 +6556,17 @@ static int check_if_compiler_support_Wno_error_unused_command_line_argument(cons
return PPKG_ERROR;
}

return try_compile(compiler, "-Wno-error=unused-command-line-argument", testCFilePath);
size_t compilerOptionCapacity = strlen(ccflags) + strlen(ldflags) + 42U;
char compilerOption[compilerOptionCapacity];

ret = snprintf(compilerOption, compilerOptionCapacity, "-Wno-error=unused-command-line-argument %s %s" , ccflags, ldflags);

if (ret < 0) {
perror(NULL);
return PPKG_ERROR;
}

return try_compile(compiler, compilerOption, testCFilePath);
}

int ppkg_setup_toolchain_for_native_build(
Expand Down Expand Up @@ -6650,8 +6660,8 @@ int ppkg_setup_toolchain_for_native_build(

//////////////////////////////////////////////////////////////////////////////

int ret1 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cc, true);
int ret2 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cxx, true);
int ret1 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cc, true, toolchainForNativeBuild->ccflags, toolchainForNativeBuild->ldflags);
int ret2 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cxx, true, toolchainForNativeBuild->cxxflags, toolchainForNativeBuild->ldflags);

//////////////////////////////////////////////////////////////////////////////

Expand All @@ -6661,7 +6671,7 @@ int ppkg_setup_toolchain_for_native_build(

//////////////////////////////////////////////////////////////////////

char * fields[3] = {NULL};
char* fields[3] = {NULL};

for (int i = 0; i < 3; i++) {
size_t capacity = ppkgCoreDIRLength + 21U;
Expand Down

0 comments on commit 4261efa

Please sign in to comment.