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

Compiler flags for Python bindings #13

Closed
wvxvw opened this issue Feb 18, 2014 · 5 comments
Closed

Compiler flags for Python bindings #13

wvxvw opened this issue Feb 18, 2014 · 5 comments
Assignees

Comments

@wvxvw
Copy link

wvxvw commented Feb 18, 2014

I've tried to build Python bindings (using compile.sh) and weeding through the compiler warnings and errors I figured that:

  • I had to specify -fPIC (otherwise it won't link wgdb.so).
  • The -march option has an unorthodox value (and was rejected, I had to remove it). Man page for gcc says:
       -march=name
           This specifies the name of the target ARM architecture.  GCC uses this name to determine what kind of
           instructions it can emit when generating assembly code.  This option can be used in conjunction with or
           instead of the -mcpu= option.  Permissible names are: armv2, armv2a, armv3, armv3m, armv4, armv4t,
           armv5, armv5t, armv5e, armv5te, armv6, armv6j, armv6t2, armv6z, armv6zk, armv6-m, armv7, armv7-a,
           armv7-r, armv7-m, iwmmxt, iwmmxt2, ep9312.

           -march=native causes the compiler to auto-detect the architecture of the build computer.  At present,
           this feature is only supported on Linux, and not all architectures are recognized.  If the auto-detect
           is unsuccessful the option has no effect.

Its current value is pentium4 which seems to be a mistake.

After I've done both, I could compile it, and the Python code using wgdb library ran (although I did no extensive testing). I'm using gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8).

@priitj
Copy link
Owner

priitj commented Feb 18, 2014

Thank you.

I'm actually well aware that -fPIC is required on some systems and that the -march=pentium4 isn't necessarily correct or useful.

compile.sh way of building is meant for people who know what they are doing and can't or won't use autotools or even the make utility for some reason. Such a basic script can't reasonably be expected to compile everywhere without some tweaking, this is why things like autotools exist and thrive. Since autotools provide a way of making things work out of the box for a variety of platforms, the "alternative" scripts basically go unmaintained.

However, I'm quite willing to modify these old scripts so that they would work on a wider variety of current platforms. As I understand, your proposal is to add '-fPIC' and remove '-march'. If anybody following this has comments or alternative suggestions, I'd be happy to hear (or read) them.

@wvxvw
Copy link
Author

wvxvw commented Feb 19, 2014

I've tried building with Automake first, and while it builds the rest of the projects, it doesn't build Python bindings (at least for me). When I then tried to build the Makefile in Python directory, I've got an error that I couldn't really understand. It complained about not finding -lwgdb (which I thought it was supposed to build...) or something like that. Sorry, I'm no good with these things :) So I tried the alternative and could "make it work". I'll try it once again this evening to see what the exact problem was.

@priitj
Copy link
Owner

priitj commented Feb 19, 2014

Can you post the output of "./configure --with-python"?

@wvxvw
Copy link
Author

wvxvw commented Feb 19, 2014

Ouch, sorry, I didn't know there was a --with-python option. It builds and installs just fine, if I do it like that. Here's the output for completeness:

configure: ====== initialising ======
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1635000
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: ====== checking ======
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking whether gcc and cc understand -c and -o together... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for cos in -lm... yes
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.7/site-packages
checking for python extension module directory... ${exec_prefix}/lib64/python2.7/site-packages
checking for headers required to compile python extensions... found
checking for raptor-config... no
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... none needed
checking whether yytext is a pointer... no
checking for bison... bison
checking linux/futex.h usability... yes
checking linux/futex.h presence... yes
checking for linux/futex.h... yes
configure: ====== setting configuration options ======
checking for logging... disabled
checking for locking protocol... tfqueue
checking for additional validation checks... enabled
checking for single-compare T-tree mode... enabled
checking for chained T-tree nodes algorithm... enabled
checking for backlinking... enabled
checking for child db support... disabled
checking for index templates... enabled
checking for reasoner... disabled
checking string hash size... 2
configure: ====== setting compiler flags ======
checking for gcc architecture flag... 
checking for x86 cpuid 0 output... d:756e6547:6c65746e:49656e69
checking for x86 cpuid 1 output... 206a7:3100800:1dbae3bf:bfebfbff
checking whether C compiler accepts -march=pentium2... no
checking whether C compiler accepts -mcpu=pentium2... no
checking whether C compiler accepts -mpentium2... no
checking whether C compiler accepts -march=pentiumpro... no
checking whether C compiler accepts -mcpu=pentiumpro... no
checking whether C compiler accepts -mpentiumpro... no
checking for gcc architecture flag... unknown
checking whether CC supports -m64... yes
checking for gprof... no
configure: ====== final steps ======
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating Db/Makefile
config.status: creating json/Makefile
config.status: creating Main/Makefile
config.status: creating Examples/Makefile
config.status: creating Python/Makefile
config.status: creating Parser/Makefile
config.status: creating Printer/Makefile
config.status: creating Reasoner/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

@priitj
Copy link
Owner

priitj commented Feb 19, 2014

Glad that worked out for you.

Will keep the issue open for now, until a decision is made about the compile.sh scripts.

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

No branches or pull requests

2 participants