Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pipcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ def build_extension(
A string, or a sequence of library names. Each item is prefixed
with `-l` on non-Windows.
optimise:
Whether to use compiler optimisations.
Whether to use compiler optimisations and define NDEBUG.
debug:
Whether to build with debug symbols.
compiler_extra:
Expand Down
26 changes: 14 additions & 12 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ def build():
cc_base, _ = pipcl.base_compiler(cpp=True)
ld_base, _ = pipcl.base_linker(cpp=True)
pipcl.run(f'mkdir -p {testdir}/build')
pipcl.run(f'{{cc_base}} -DNDEBUG -fPIC -c -o {testdir}/build/qwerty.o {testdir}/qwerty.cpp')
pipcl.run(f'{{cc_base}} -fPIC -c -o {testdir}/build/qwerty.o {testdir}/qwerty.cpp')
pipcl.run(f'{{ld_base}} -o {testdir}/build/libqwerty.so {testdir}/build/qwerty.o')

so_leaf = pipcl.build_extension(
Expand All @@ -957,6 +957,7 @@ def build():
outdir = 'build',
libpaths = '{testdir}/build',
libs = ['qwerty'],
optimise = False,
)

return [
Expand Down Expand Up @@ -984,27 +985,29 @@ def build():
with open(f'{testdir}/foo.i', 'w') as f:
f.write(textwrap.dedent('''
%{
#include <stdexcept>

#include <assert.h>
#include <setjmp.h>
#include <stdio.h>
#include <string.h>
#include <stdexcept>

int qwerty(void);

static sigjmp_buf jmpbuf;
static int bar0(const char* text)
{
printf("bar(): text: %s\\n", text);
printf("bar0(): text: %s\\n", text);

int q = qwerty();
printf("bar(): q=%i\\n", q);
printf("bar0(): q=%i\\n", q);

int len = (int) strlen(text);
printf("bar(): len=%i\\\\n", len);
//printf("calling longjmp().\\n");
//longjmp(jmpbuf, 1);
printf("bar0(): len=%i\\n", len);
printf("bar0(): calling longjmp().\\n");
fflush(stdout);
return len;
longjmp(jmpbuf, 1);
assert(0);
}
int bar1(const char* text)
{
Expand All @@ -1015,11 +1018,10 @@ def build():
}
else
{
printf("setjmp() returned non-zero.\\n");
printf("bar1(): setjmp() returned non-zero.\\n");
throw std::runtime_error("deliberate exception");
}
throw std::runtime_error("deliberate exception");
return ret;
assert(0);
}
int bar(const char* text)
{
Expand All @@ -1030,7 +1032,7 @@ def build():
}
catch(std::exception& e)
{
printf("Received exception: %s\\n", e.what());
printf("bar1(): received exception: %s\\n", e.what());
}
return ret;
}
Expand Down
Loading