Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static linking issue encountered during stable build #3259

Merged
merged 3 commits into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/libponyc/codegen/genexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ static bool link_exe(compile_t* c, ast_t* program,
env_cc_or_pony_compiler(&fallback_linker);
const char* mcx16_arg = (target_is_lp64(c->opt->triple)
&& target_is_x86(c->opt->triple)) ? "-mcx16" : "";
const char* fuseld = target_is_linux(c->opt->triple) ? "-fuse-ld=gold" : "";
const char* fuseldcmd = c->opt->link_ldcmd != NULL ? c->opt->link_ldcmd :
(target_is_linux(c->opt->triple) ? "gold" : "");
const char* fuseld = strlen(fuseldcmd) ? "-fuse-ld=" : "";
const char* ldl = target_is_linux(c->opt->triple) ? "-ldl" : "";
const char* atomic = target_is_linux(c->opt->triple) ? "-latomic" : "";
const char* staticbin = c->opt->staticbin ? "-static" : "";
Expand Down Expand Up @@ -371,7 +373,7 @@ static bool link_exe(compile_t* c, ast_t* program,
size_t ld_len = 512 + strlen(file_exe) + strlen(file_o) + strlen(lib_args)
+ strlen(arch) + strlen(mcx16_arg) + strlen(fuseld)
+ strlen(ldl) + strlen(atomic) + strlen(staticbin)
+ strlen(dtrace_args) + strlen(lexecinfo)
+ strlen(dtrace_args) + strlen(lexecinfo) + strlen(fuseldcmd)
+ strlen(sanitizer_arg);

char* ld_cmd = (char*)ponyint_pool_alloc_size(ld_len);
Expand All @@ -389,12 +391,12 @@ static bool link_exe(compile_t* c, ast_t* program,
#endif
#ifdef PLATFORM_IS_OPENBSD
// On OpenBSD, the unwind symbols are contained within libc++abi.
"%s %s %s %s %s -lpthread %s %s %s -lm -lc++abi %s %s",
"%s %s%s %s %s -lpthread %s %s %s -lm -lc++abi %s %s %s",
#else
"%s %s %s %s %s -lpthread %s %s %s -lm %s %s",
"%s %s%s %s %s -lpthread %s %s %s -lm %s %s %s",
#endif
linker, file_exe, arch, mcx16_arg, atomic, staticbin, fuseld, file_o,
lib_args, dtrace_args, ponyrt, ldl, lexecinfo, sanitizer_arg
linker, file_exe, arch, mcx16_arg, staticbin, fuseld, fuseldcmd, file_o,
lib_args, dtrace_args, ponyrt, ldl, lexecinfo, atomic, sanitizer_arg
);

if(c->opt->verbosity >= VERBOSITY_TOOL_INFO)
Expand Down
5 changes: 5 additions & 0 deletions src/libponyc/options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum
OPT_STATS,
OPT_LINK_ARCH,
OPT_LINKER,
OPT_LINK_LDCMD,
OPT_PLUGIN,

OPT_VERBOSE,
Expand Down Expand Up @@ -90,6 +91,7 @@ static opt_arg_t std_args[] =
{"stats", '\0', OPT_ARG_NONE, OPT_STATS},
{"link-arch", '\0', OPT_ARG_REQUIRED, OPT_LINK_ARCH},
{"linker", '\0', OPT_ARG_REQUIRED, OPT_LINKER},
{"link-ldcmd", '\0', OPT_ARG_REQUIRED, OPT_LINK_LDCMD},
{"plugin", '\0', OPT_ARG_REQUIRED, OPT_PLUGIN},

{"verbose", 'V', OPT_ARG_REQUIRED, OPT_VERBOSE},
Expand Down Expand Up @@ -159,6 +161,8 @@ static void usage(void)
" =name Default is the host architecture.\n"
" --linker Set the linker command to use.\n"
" =name Default is the compiler used to compile ponyc.\n"
" --link-ldcmd Set the ld command to use.\n"
" =name Default is `gold` on linux and system default otherwise.\n"
" --plugin Use the specified plugin(s).\n"
" =name\n"
" --define, -D Set a compile time definition.\n"
Expand Down Expand Up @@ -341,6 +345,7 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt,
case OPT_STATS: opt->print_stats = true; break;
case OPT_LINK_ARCH: opt->link_arch = s->arg_val; break;
case OPT_LINKER: opt->linker = s->arg_val; break;
case OPT_LINK_LDCMD: opt->link_ldcmd = s->arg_val; break;
case OPT_PLUGIN:
if(!plugin_load(opt, s->arg_val))
{
Expand Down
1 change: 1 addition & 0 deletions src/libponyc/pass/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ typedef struct pass_opt_t
const char* bin_name;
char* link_arch;
char* linker;
char* link_ldcmd;

char* triple;
char* cpu;
Expand Down