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 build error on Linux - 'bool' undefined #1

Closed
wants to merge 1 commit into from
Closed

Fix build error on Linux - 'bool' undefined #1

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 4, 2015

Building with a Fedora22 distribution, on x86-64 gives many errors:

gcc perl -MExtUtils::Embed -e ccopts -fPIC -c -o khmm_wrap.o khmm_wrap.c
In file included from khmm_wrap.c:730:0:
khmm_wrap.c: In function ‘SWIG_AsCharPtrAndSize’:
/usr/lib64/perl5/CORE/handy.h:124:34: error: ‘bool’ undeclared (first use in this function)
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
^
/usr/lib64/perl5/CORE/perl.h:3158:62: note: in definition of macro ‘EXPECT’

define EXPECT(expr,val) __builtin_expect(expr,val)

                                                          ^

/usr/lib64/perl5/CORE/perl.h:3162:52: note: in expansion of macro ‘cBOOL’
#define LIKELY(cond) EXPECT(cBOOL(cond),TRUE)

...

Removing the '#undef bool' from khmm_wrap.c fixes these, and allows a successful build.

Signed-off-by: Mark Einon mark.einon@gmail.com

Building with a Fedora22 distribution, on x86-64 gives many errors:

gcc `perl -MExtUtils::Embed -e ccopts` -fPIC   -c -o khmm_wrap.o khmm_wrap.c
In file included from khmm_wrap.c:730:0:
khmm_wrap.c: In function ‘SWIG_AsCharPtrAndSize’:
/usr/lib64/perl5/CORE/handy.h:124:34: error: ‘bool’ undeclared (first use in this function)
 #define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
                                  ^
/usr/lib64/perl5/CORE/perl.h:3158:62: note: in definition of macro ‘EXPECT’
 #  define EXPECT(expr,val)                  __builtin_expect(expr,val)
                                                              ^
/usr/lib64/perl5/CORE/perl.h:3162:52: note: in expansion of macro ‘cBOOL’
 #define LIKELY(cond)                        EXPECT(cBOOL(cond),TRUE)

...

Removing the '#undef bool' from khmm_wrap.c fixes these, and allows a successful build.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
@kaichop
Copy link
Contributor

kaichop commented Aug 4, 2015

Which perl version are you using?
It is known that perl over 5.14 causes problems with "bool". You may want
to install a new perl locally, or use perlbrew.

On Tue, Aug 4, 2015 at 5:54 AM, Mark Einon notifications@github.com wrote:

Building with a Fedora22 distribution, on x86-64 gives many errors:

gcc perl -MExtUtils::Embed -e ccopts -fPIC -c -o khmm_wrap.o khmm_wrap.c
In file included from khmm_wrap.c:730:0:
khmm_wrap.c: In function ‘SWIG_AsCharPtrAndSize’:
/usr/lib64/perl5/CORE/handy.h:124:34: error: ‘bool’ undeclared (first use
in this function)
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
^
/usr/lib64/perl5/CORE/perl.h:3158:62: note: in definition of macro ‘EXPECT’

define EXPECT(expr,val) __builtin_expect(expr,val)

^
/usr/lib64/perl5/CORE/perl.h:3162:52: note: in expansion of macro ‘cBOOL’
#define LIKELY(cond) EXPECT(cBOOL(cond),TRUE)

...

Removing the '#undef bool' from khmm_wrap.c fixes these, and allows a
successful build.

Signed-off-by: Mark Einon mark.einon@gmail.com

You can view, comment on, or merge this pull request online at:

#1
Commit Summary

  • Fix build error on Linux - 'bool' undefined

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#1.

@ghost
Copy link
Author

ghost commented Aug 6, 2015

Thanks for the prompt reply.

It was perl 5.20.

So I've attempted to build perl 5.14, which builds fine, but running exercise 1 from the PennCNV/example directory ends unexpectedly after attempting to process the first file:

Exercise 1: individual-based calling and write the output to ex1.rawcnv
Running command <detect_cnv.pl -test -hmm example.hmm -pfb example.pfb -conf -log ex1.log -out ex1.rawcnv father.txt mother.txt offspring.txt>


NOTICE: All program notification/warning messages that appear in STDERR will be also written to log file ex1.log
NOTICE: Reading marker coordinates and population frequency of B allele (PFB) from example.pfb ... Done with 93129 records
NOTICE: Reading LRR and BAF values for from father.txt ... Done with 93129 records in 4 chromosomes
NOTICE: Data from chromosome X will not be used in analysis
NOTICE: Median-adjusting LRR values for all autosome markers from father.txt by 0.0221
NOTICE: Median-adjusting BAF values for all autosome markers from father.txt by 0.0029
NOTICE: quality summary for father.txt: LRR_mean=0.0027 LRR_median=0.0000 LRR_SD=0.1335 BAF_mean=0.5063 BAF_median=0.5000 BAF_SD=0.0390 BAF_DRIFT=0.000037 WF=0.0184 GCWF=0.0136


From running this with strace, I can see a fork happening followed by a SIGINT/SIGQUIT, and a core gets dumped if run outside of the runex.pl script. I haven't debugged any further.

...
write(2, "Exercise 1: individual-based cal"..., 216) = 216
write(2, "\n*******************************"..., 80) = 80
pipe([3, 4]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f77a59079d0) = 25648
close(4) = 0
rt_sigaction(SIGINT, {SIG_IGN, [], SA_RESTORER, 0x7f77a499f430}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7f77a499f430}, {SIG_DFL, [], 0}, 8) = 0
wait4(25648, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV && WCOREDUMP(s)}], 0, NULL) = 25648
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_DUMPED, si_pid=25648, si_uid=1000, si_status=SIGSEGV, si_utime=115, si_stime=5} ---
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f77a499f430}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f77a499f430}, NULL, 8) = 0
read(3, "", 4) = 0
close(3) = 0
...

@kaichop
Copy link
Contributor

kaichop commented Aug 7, 2015

When you "make", did you try "make clean" first, and delete all the *.o
files from previous make (perl 5.20)?
Can you show the message from the "make" command?

On Thu, Aug 6, 2015 at 8:21 AM, Mark Einon notifications@github.com wrote:

Thanks for the prompt reply.

It was perl 5.20.

So I've attempted to build perl 5.14, which builds fine, but running
exercise 1 from the PennCNV/example directory ends unexpectedly after
attempting to process the first file:

Exercise 1: individual-based calling and write the output to ex1.rawcnv

Running command

NOTICE: All program notification/warning messages that appear in STDERR
will be also written to log file ex1.log
NOTICE: Reading marker coordinates and population frequency of B allele
(PFB) from example.pfb ... Done with 93129 records
NOTICE: Reading LRR and BAF values for from father.txt ... Done with 93129
records in 4 chromosomes
NOTICE: Data from chromosome X will not be used in analysis
NOTICE: Median-adjusting LRR values for all autosome markers from
father.txt by 0.0221
NOTICE: Median-adjusting BAF values for all autosome markers from
father.txt by 0.0029
NOTICE: quality summary for father.txt: LRR_mean=0.0027 LRR_median=0.0000
LRR_SD=0.1335 BAF_mean=0.5063 BAF_median=0.5000 BAF_SD=0.0390

BAF_DRIFT=0.000037 WF=0.0184 GCWF=0.0136

From running this with strace, I can see a fork happening followed by a
SIGINT/SIGQUIT, and a core gets dumped if run outside of the runex.pl
script. I have;nt debugged any further.

...
write(2, "Exercise 1: individual-based cal"..., 216) = 216
write(2, "\n*******************************"..., 80) = 80
pipe([3, 4]) = 0
clone(child_stack=0,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
child_tidptr=0x7f77a59079d0) = 25648
close(4) = 0
rt_sigaction(SIGINT, {SIG_IGN, [], SA_RESTORER, 0x7f77a499f430}, {SIG_DFL,
[], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7f77a499f430},
{SIG_DFL, [], 0}, 8) = 0
wait4(25648, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV && WCOREDUMP(s)}],
0, NULL) = 25648
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_DUMPED, si_pid=25648,
si_uid=1000, si_status=SIGSEGV, si_utime=115, si_stime=5} ---
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f77a499f430}, NULL, 8)
= 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f77a499f430}, NULL, 8)
= 0
read(3, "", 4) = 0
close(3) = 0
...


Reply to this email directly or view it on GitHub
#1 (comment)
.

@ghost
Copy link
Author

ghost commented Aug 7, 2015

Sure, this is using perl 5.14.2:

[mark@einonmac kext]$ which perl
~/usr/perl-5.14.2/bin/perl
[mark@einonmac kext]$ make clean
rm -f *.o *.so
[mark@einonmac kext]$ make
gcc `perl -MExtUtils::Embed -e ccopts` -fPIC -g   -c -o khmm_wrap.o khmm_wrap.c
gcc `perl -MExtUtils::Embed -e ccopts` -fPIC -g   -c -o khmm.o khmm.c
gcc `perl -MExtUtils::Embed -e ccopts` -fPIC -g   -c -o kc.o kc.c
gcc `perl -MExtUtils::Embed -e ccopts` -fPIC -g   -c -o khmmDev.o khmmDev.c
gcc -shared -o khmm.so khmm_wrap.o khmm.o kc.o khmmDev.o `perl -MExtUtils::Embed -e ldopts`
mkdir -p `perl -MConfig -e 'print $Config{version}'`
mkdir -p `perl -MConfig -e 'print $Config{version}'`/`perl -MConfig -e 'print $Config{archname}'`/
mkdir -p `perl -MConfig -e 'print $Config{version}'`/`perl -MConfig -e 'print $Config{archname}'`/auto/
mv khmm.so `perl -MConfig -e 'print $Config{version}'`/`perl -MConfig -e 'print $Config{archname}'`/

If it's of any help, the program segfaults after calling khmm::testVit_CHMM() at detect_cnv.pl:888, no subsequent debug lines are output. The last parameter is zero, which is interesting, as that gets dereferenced by khmm::testVit_CHMM(), which I assume is the cause.

[mark@einonmac example]$ perl  ../detect_cnv.pl -test -hmm example.hmm -pfb example.pfb -conf -log ex1.log -out ex1.rawcnv father.txt mother.txt offspring.txt
NOTICE: All program notification/warning messages that appear in STDERR will be also written to log file ex1.log
NOTICE: Reading marker coordinates and population frequency of B allele (PFB) from example.pfb ... Done with 93129 records
NOTICE: Reading LRR and BAF values for from father.txt ... Done with 93129 records in 4 chromosomes
NOTICE: Data from chromosome X will not be used in analysis
NOTICE: Median-adjusting LRR values for all autosome markers from father.txt by 0.0221
NOTICE: Median-adjusting BAF values for all autosome markers from father.txt by 0.0029
NOTICE: quality summary for father.txt: LRR_mean=0.0027 LRR_median=0.0000 LRR_SD=0.1335 BAF_mean=0.5063 BAF_median=0.5000 BAF_SD=0.0390 BAF_DRIFT=0.000037 WF=0.0184 GCWF=0.0136
detect_cnv.pl:888, call khmm::testVit_CHMM (hmm_model, 27272, ARRAY(0x5017790), ARRAY(0x50177d8), ARRAY(0x3a49220), ARRAY(0x7157b10), 0)
Segmentation fault (core dumped)

@kaichop
Copy link
Contributor

kaichop commented Aug 10, 2015

From the output, I cannot really tell what is the problem, but at least the compilation on 5.14 looks okay to me, unlike 5.20.

My guess is that there may be an out of memory error. It will take between 4-8Gb memory on a 64-bit machine based on my experience, for each sample.

But to help you run PennCNV, I just uploaded *.so files at https://github.com/WangGenomicsLab/PennCNV/tree/master/kext/5.14.2/x86_64-linux-thread-multi. (I did not know which 5.14 you are using, so I made 5.14.2 files there). You should be able to directly download and use them, without compilation, assuming that you have threaded version of 64-bit Perl.

@ghost
Copy link
Author

ghost commented Aug 10, 2015

Thanks you - your version of the library works fine with all other things being equal (I'm certain it's not a memory issue, I have 16GB + 8GB of swap, and the memory usage doesn't top out).

If we are building the same library version (the ko files do differ by about 120k), then could be due to the differing gcc versions or compiler flags used, I'm using 5.1.1 and your library is built with 4.7.7.

@kaichop
Copy link
Contributor

kaichop commented Aug 10, 2015

Okay, thanks for letting me know.

On Mon, Aug 10, 2015 at 5:03 AM, Mark Einon notifications@github.com
wrote:

Thanks you - your version of the library works fine with all other things
being equal (I'm certain it's not a memory issue, I have 16GB + 8GB of
swap, and the memory usage doesn't top out).

If we are building the same library version (the ko files do differ by
about 120k), then could be due to the differing gcc versions or compiler
flags used, I'm using 5.1.1 and your library is built with 4.7.7.


Reply to this email directly or view it on GitHub
#1 (comment)
.

@ghost ghost closed this Aug 10, 2015
@ghost
Copy link
Author

ghost commented Aug 10, 2015

Thanks for your help, closing the original pull request.
I've since tried the build on Centos 6, and it works fine - However Centos 7 (and Fedora 22) both show this issue.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants