You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/05/16 15:37:52 UTC
[06/10] lucy-clownfish git commit: Use Charmonizer linker flags for
Perl module
Use Charmonizer linker flags for Perl module
Additional libraries should be specified when linking the Perl module.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/b083881b
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/b083881b
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/b083881b
Branch: refs/heads/master
Commit: b083881b4af638b4a6aa8444c33cf1b5e6e9ac18
Parents: 42fc9a4
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun May 10 15:48:06 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue May 12 20:15:25 2015 +0200
----------------------------------------------------------------------
runtime/common/charmonizer.c | 55 ++++++++++++++++++---------
runtime/common/charmonizer.main | 55 ++++++++++++++++++---------
runtime/perl/buildlib/Clownfish/Build.pm | 8 ++++
3 files changed, 84 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b083881b/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index b7d5383..e3f4f2f 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -7828,6 +7828,9 @@ static const char cfish_major_version[] = "0.4";
static void
S_add_compiler_flags(struct chaz_CLI *cli);
+static chaz_CFlags*
+S_link_flags(chaz_CLI *cli);
+
static cfish_MakeFile*
cfish_MakeFile_new(chaz_CLI *cli);
@@ -7835,7 +7838,7 @@ static void
cfish_MakeFile_destroy(cfish_MakeFile *self);
static void
-cfish_MakeFile_write(cfish_MakeFile *self);
+cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags);
static void
cfish_MakeFile_write_c_cfc_rules(cfish_MakeFile *self);
@@ -7856,6 +7859,8 @@ static int
S_need_libpthread(chaz_CLI *cli);
int main(int argc, const char **argv) {
+ chaz_CFlags *link_flags;
+
/* Initialize. */
chaz_CLI *cli
= chaz_CLI_new(argv[0], "charmonizer: Probe C build environment");
@@ -7895,14 +7900,20 @@ int main(int argc, const char **argv) {
chaz_Memory_run();
chaz_VariadicMacros_run();
- /* Write custom postamble. */
+ /* Local definitions. */
+ chaz_ConfWriter_start_module("LocalDefinitions");
if (chaz_HeadCheck_check_header("sys/time.h")) {
- chaz_ConfWriter_append_conf("#define CHY_HAS_SYS_TIME_H\n\n");
+ chaz_ConfWriter_add_def("HAS_SYS_TIME_H", NULL);
}
if (chaz_HeadCheck_defines_symbol("__sync_bool_compare_and_swap", "")) {
- chaz_ConfWriter_append_conf(
- "#define CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n\n");
+ chaz_ConfWriter_add_def("HAS___SYNC_BOOL_COMPARE_AND_SWAP", NULL);
}
+ link_flags = S_link_flags(cli);
+ chaz_ConfWriter_add_def("EXTRA_LDFLAGS",
+ chaz_CFlags_get_string(link_flags));
+ chaz_ConfWriter_end_module();
+
+ /* Write custom postamble. */
chaz_ConfWriter_append_conf(
"#ifdef CHY_HAS_SYS_TYPES_H\n"
" #include <sys/types.h>\n"
@@ -7931,7 +7942,7 @@ int main(int argc, const char **argv) {
if (chaz_CLI_defined(cli, "enable-makefile")) {
cfish_MakeFile *mf = cfish_MakeFile_new(cli);
- cfish_MakeFile_write(mf);
+ cfish_MakeFile_write(mf, link_flags);
/* Export filenames. */
chaz_ConfWriter_add_def("SHARED_LIB_FILENAME",
mf->shared_lib_filename);
@@ -7941,6 +7952,7 @@ int main(int argc, const char **argv) {
}
/* Clean up. */
+ chaz_CFlags_destroy(link_flags);
chaz_CLI_destroy(cli);
chaz_Probe_clean_up();
@@ -7994,6 +8006,24 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
}
}
+static chaz_CFlags*
+S_link_flags(chaz_CLI *cli) {
+ chaz_CFlags *link_flags = chaz_CC_new_cflags();
+ const char *math_library = chaz_Floats_math_library();
+
+ if (math_library) {
+ chaz_CFlags_add_external_library(link_flags, math_library);
+ }
+ if (S_need_libpthread(cli)) {
+ chaz_CFlags_add_external_library(link_flags, "pthread");
+ }
+ if (chaz_CLI_defined(cli, "enable-coverage")) {
+ chaz_CFlags_enable_code_coverage(link_flags);
+ }
+
+ return link_flags;
+}
+
static cfish_MakeFile*
cfish_MakeFile_new(chaz_CLI *cli) {
const char *dir_sep = chaz_OS_dir_sep();
@@ -8069,7 +8099,7 @@ cfish_MakeFile_destroy(cfish_MakeFile *self) {
}
static void
-cfish_MakeFile_write(cfish_MakeFile *self) {
+cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
SourceFileContext sfc;
const char *dir_sep = chaz_OS_dir_sep();
@@ -8084,7 +8114,6 @@ cfish_MakeFile_write(cfish_MakeFile *self) {
chaz_CFlags *makefile_cflags;
chaz_CFlags *link_flags;
- const char *math_library = chaz_Floats_math_library();
char *scratch;
int i;
@@ -8156,15 +8185,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) {
link_flags = chaz_CC_new_cflags();
chaz_CFlags_enable_debugging(link_flags);
- if (math_library) {
- chaz_CFlags_add_external_library(link_flags, math_library);
- }
- if (S_need_libpthread(self->cli)) {
- chaz_CFlags_add_external_library(link_flags, "pthread");
- }
- if (chaz_CLI_defined(self->cli, "enable-coverage")) {
- chaz_CFlags_enable_code_coverage(link_flags);
- }
+ chaz_CFlags_append(link_flags, chaz_CFlags_get_string(extra_link_flags));
chaz_MakeFile_add_shared_lib(self->makefile, self->shared_lib,
"$(CLOWNFISH_OBJS)", link_flags);
chaz_CFlags_destroy(link_flags);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b083881b/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index 1602bd6..a425d10 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -69,6 +69,9 @@ static const char cfish_major_version[] = "0.4";
static void
S_add_compiler_flags(struct chaz_CLI *cli);
+static chaz_CFlags*
+S_link_flags(chaz_CLI *cli);
+
static cfish_MakeFile*
cfish_MakeFile_new(chaz_CLI *cli);
@@ -76,7 +79,7 @@ static void
cfish_MakeFile_destroy(cfish_MakeFile *self);
static void
-cfish_MakeFile_write(cfish_MakeFile *self);
+cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags);
static void
cfish_MakeFile_write_c_cfc_rules(cfish_MakeFile *self);
@@ -97,6 +100,8 @@ static int
S_need_libpthread(chaz_CLI *cli);
int main(int argc, const char **argv) {
+ chaz_CFlags *link_flags;
+
/* Initialize. */
chaz_CLI *cli
= chaz_CLI_new(argv[0], "charmonizer: Probe C build environment");
@@ -136,14 +141,20 @@ int main(int argc, const char **argv) {
chaz_Memory_run();
chaz_VariadicMacros_run();
- /* Write custom postamble. */
+ /* Local definitions. */
+ chaz_ConfWriter_start_module("LocalDefinitions");
if (chaz_HeadCheck_check_header("sys/time.h")) {
- chaz_ConfWriter_append_conf("#define CHY_HAS_SYS_TIME_H\n\n");
+ chaz_ConfWriter_add_def("HAS_SYS_TIME_H", NULL);
}
if (chaz_HeadCheck_defines_symbol("__sync_bool_compare_and_swap", "")) {
- chaz_ConfWriter_append_conf(
- "#define CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n\n");
+ chaz_ConfWriter_add_def("HAS___SYNC_BOOL_COMPARE_AND_SWAP", NULL);
}
+ link_flags = S_link_flags(cli);
+ chaz_ConfWriter_add_def("EXTRA_LDFLAGS",
+ chaz_CFlags_get_string(link_flags));
+ chaz_ConfWriter_end_module();
+
+ /* Write custom postamble. */
chaz_ConfWriter_append_conf(
"#ifdef CHY_HAS_SYS_TYPES_H\n"
" #include <sys/types.h>\n"
@@ -172,7 +183,7 @@ int main(int argc, const char **argv) {
if (chaz_CLI_defined(cli, "enable-makefile")) {
cfish_MakeFile *mf = cfish_MakeFile_new(cli);
- cfish_MakeFile_write(mf);
+ cfish_MakeFile_write(mf, link_flags);
/* Export filenames. */
chaz_ConfWriter_add_def("SHARED_LIB_FILENAME",
mf->shared_lib_filename);
@@ -182,6 +193,7 @@ int main(int argc, const char **argv) {
}
/* Clean up. */
+ chaz_CFlags_destroy(link_flags);
chaz_CLI_destroy(cli);
chaz_Probe_clean_up();
@@ -235,6 +247,24 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
}
}
+static chaz_CFlags*
+S_link_flags(chaz_CLI *cli) {
+ chaz_CFlags *link_flags = chaz_CC_new_cflags();
+ const char *math_library = chaz_Floats_math_library();
+
+ if (math_library) {
+ chaz_CFlags_add_external_library(link_flags, math_library);
+ }
+ if (S_need_libpthread(cli)) {
+ chaz_CFlags_add_external_library(link_flags, "pthread");
+ }
+ if (chaz_CLI_defined(cli, "enable-coverage")) {
+ chaz_CFlags_enable_code_coverage(link_flags);
+ }
+
+ return link_flags;
+}
+
static cfish_MakeFile*
cfish_MakeFile_new(chaz_CLI *cli) {
const char *dir_sep = chaz_OS_dir_sep();
@@ -310,7 +340,7 @@ cfish_MakeFile_destroy(cfish_MakeFile *self) {
}
static void
-cfish_MakeFile_write(cfish_MakeFile *self) {
+cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
SourceFileContext sfc;
const char *dir_sep = chaz_OS_dir_sep();
@@ -325,7 +355,6 @@ cfish_MakeFile_write(cfish_MakeFile *self) {
chaz_CFlags *makefile_cflags;
chaz_CFlags *link_flags;
- const char *math_library = chaz_Floats_math_library();
char *scratch;
int i;
@@ -397,15 +426,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) {
link_flags = chaz_CC_new_cflags();
chaz_CFlags_enable_debugging(link_flags);
- if (math_library) {
- chaz_CFlags_add_external_library(link_flags, math_library);
- }
- if (S_need_libpthread(self->cli)) {
- chaz_CFlags_add_external_library(link_flags, "pthread");
- }
- if (chaz_CLI_defined(self->cli, "enable-coverage")) {
- chaz_CFlags_enable_code_coverage(link_flags);
- }
+ chaz_CFlags_append(link_flags, chaz_CFlags_get_string(extra_link_flags));
chaz_MakeFile_add_shared_lib(self->makefile, self->shared_lib,
"$(CLOWNFISH_OBJS)", link_flags);
chaz_CFlags_destroy(link_flags);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b083881b/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build.pm b/runtime/perl/buildlib/Clownfish/Build.pm
index a4d52c5..c91649f 100644
--- a/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/runtime/perl/buildlib/Clownfish/Build.pm
@@ -161,6 +161,14 @@ sub ACTION_compile_custom_xs {
$self->clownfish_params( cflags => $cf_cflags );
}
+ # Add extra linker flags from Charmonizer.
+ my $charm_ldflags = $self->charmony('EXTRA_LDFLAGS');
+ if ($charm_ldflags) {
+ my $extra_ldflags = $self->extra_linker_flags;
+ push @$extra_ldflags, $self->split_like_shell($charm_ldflags);
+ $self->extra_linker_flags(@$extra_ldflags);
+ }
+
$self->SUPER::ACTION_compile_custom_xs;
}