gcc, 64 bit, oracle, solaris - oracle

info#s490up # gcc -std=gnu99 -o bla -g -O2 -DSunOS=1 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES= -I/usr/include/libxml2 -I/u/app/oracle/product/11.2/rdbms/demo -I/u/app/oracle/product/11.2/rdbms/public -I/u/app/oracle/product/11.2/rdbms/demo -I/u/app/oracle/product/11.2/rdbms/public blabla.c -lclntsh -lrt -lresolv -lnsl -lsocket -lm -lpthread -liconv -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl -L/u/app/oracle/product/11.2/lib
ld: fatal: file /u/app/oracle/product/11.2/lib/libclntsh.so: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to bla
collect2: ld returned 1 exit status
Can anyone give me an idea why ld does not work correctly here
(this long command has been taken from configure which is not performing right, because of this error)
UPD
file /u/app/oracle/product/11.2/lib/libclntsh.so
/u/app/oracle/product/11.2/lib/libclntsh.so: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped
The blabla.c:
info#s490up # cat /tmp/blabla.c
/* confdefs.h. */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define GW_NAME "Kannel"
#define GW_VERSION "1.4.3"
#define VERSION "1.4.3"
#define YYTEXT_POINTER 1
#define _FILE_OFFSET_BITS 64
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define HAVE_LIBM 1
#define HAVE_LIBSOCKET 1
#define HAVE_LIBNSL 1
#define HAVE_LIBRESOLV 1
#define STDC_HEADERS 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_GETOPT_H 1
#define HAVE_SYSLOG_H 1
#define HAVE_ICONV_H 1
#define HAVE_ZLIB_H 1
#define HAVE_STDLIB_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_SOCKIO_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NET_IF_H 1
#define HAVE___FUNCTION__ 1
#define HAVE___FUNC__ 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_SELECT 1
#define HAVE_SOCKET 1
#define HAVE_STRDUP 1
#define HAVE_GETOPT_LONG 1
#define HAVE_LOCALTIME_R 1
#define HAVE_GMTIME_R 1
#define HAVE_SRANDOM 1
#define HAVE_FUNC_GETHOSTBYNAME_R_5 1
#define HAVE_SOCKLEN_T 1
#define HAVE_GETOPT_IN_STDIO_H 1
#define HAVE_REGEX_H 1
#define HAVE_REGEX 1
#define HAVE_PTHREAD_SPINLOCK_T 1
#define HAVE_PTHREAD_RWLOCK 1
#define HAVE_LIBRT 1
#define HAVE_SEMAPHORE 1
#define SUFFIX ""
#define USE_GWMEM_NATIVE 1
#define LOG_TIMESTAMP_LOCALTIME 1
#define ENABLE_COOKIES 1
#define USE_KEEPALIVE 1
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char OCIEnvCreate ();
int
main ()
{
return OCIEnvCreate ();
;
return 0;
}

libclntsh.so is a 64 bit binary library which you are linking with a 32bit code. Check to make sure you have the right library.
Edit:
ELF 64-bit MSB dynamic lib SPARCV9
Version 1, dynamically linked, not
stripped
GCC 64-bit toolchain is having trouble linking against a library built on Sparc platform which could mean either one of two things
Endianess? One thing that is not clear, what platform are you running the gcc toolchain under?
Issue this command gcc --version and also run this command file /usr/bin/gcc to determine the executable's binary type. And compare the results with what's the library's binary type is...

Related

Have GAS generate instruction from inline assembly?

I'm trying to assemble a file that uses ARM's CRC instruction. The assembler is producing an error Error: selected processor does not support 'crc32b w1,w0,w0'.
There are runtime checks in place, so we are safe with the instruction. The technique works fine on i686 and x86_64. For example, I can assemble a file that uses Intel CRC intrinsics or SHA Intrinsics without -mcrc or -msha (and on a machine without the features).
Here is the test case:
$ cat test.cxx
#include <arm_neon.h>
#define GCC_INLINE_ATTRIB __attribute__((__gnu_inline__, __always_inline__, __artificial__))
#if defined(__GNUC__) && !defined(__ARM_FEATURE_CRC32)
__inline unsigned int GCC_INLINE_ATTRIB
CRC32B(unsigned int crc, unsigned char v)
{
unsigned int r;
asm ("crc32b %w2, %w1, %w0" : "=r"(r) : "r"(crc), "r"((unsigned int)v));
return r;
}
#else
// Use the intrinsic
# define CRC32B(a,b) __crc32b(a,b)
#endif
int main(int argc, char* argv[])
{
return CRC32B(argc, argc);
}
And here is the result:
$ g++ test.cxx -c
/tmp/ccqHBPUf.s: Assembler messages:
/tmp/ccqHBPUf.s:23: Error: selected processor does not support `crc32b w1,w0,w0'
Placing the ASM code in a source file and compiling with different options is not feasible because CRC32B will be used in C++ header files, too.
How do I get GAS to assemble the instruction?
GCC's configuration and options are the reason we are trying to do things this way. User's don't read manuals, so they won't add -march=armv8-a+crc+crypto -mtune=cortex-a53 to CFLAGS and CXXFLAGS.
In addition, distros compile to a "least capable" machine, so we want the hardware acceleration routines available. When the library is provided by a distro like Linaro, both code paths (software CRC and hardware accelerated CRC) will be available.
The machine is a LeMaker HiKey, which is ARMv8/Aarch64. It has an A53 processor with CRC and Crypto (CRC and Crypto is optional under the architecture):
$ cat /proc/cpuinfo
Processor : AArch64 Processor rev 3 (aarch64)
processor : 0
...
processor : 7
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: AArch64
GCC lacks most of the usual defines one expects to be present by default:
$ g++ -dM -E - </dev/null | sort | egrep -i '(arm|neon|aarch|asimd)'
#define __aarch64__ 1
#define __AARCH64_CMODEL_SMALL__ 1
#define __AARCH64EL__ 1
Using GCC's -march=native does not work on ARM:
$ g++ -march=native -dM -E - </dev/null | sort | egrep -i '(arm|neon|aarch|asimd)'
cc1: error: unknown value ‘native’ for -march
And Clang:
$ clang++ -dM -E - </dev/null | sort | egrep -i '(arm|neon|aarch|asimd)'
#define __AARCH64EL__ 1
#define __ARM_64BIT_STATE 1
#define __ARM_ACLE 200
#define __ARM_ALIGN_MAX_STACK_PWR 4
#define __ARM_ARCH 8
#define __ARM_ARCH_ISA_A64 1
#define __ARM_ARCH_PROFILE 'A'
#define __ARM_FEATURE_CLZ 1
#define __ARM_FEATURE_DIV 1
#define __ARM_FEATURE_FMA 1
#define __ARM_FEATURE_UNALIGNED 1
#define __ARM_FP 0xe
#define __ARM_FP16_FORMAT_IEEE 1
#define __ARM_FP_FENV_ROUNDING 1
#define __ARM_NEON 1
#define __ARM_NEON_FP 0xe
#define __ARM_PCS_AAPCS64 1
#define __ARM_SIZEOF_MINIMAL_ENUM 4
#define __ARM_SIZEOF_WCHAR_T 4
#define __aarch64__ 1
GCC version:
$ gcc -v
...
gcc version 4.9.2 (Debian/Linaro 4.9.2-10)
GAS version:
$ as -v
GNU assembler version 2.24 (aarch64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.24
This answer came from Jiong Wang on the Binutils mailing list. It bypasses GAS's architectural requirements and plays well with GCC:
__inline unsigned int GCC_INLINE_ATTRIB
CRC32W(unsigned int crc, unsigned int val)
{
#if 1
volatile unsigned int res;
asm ("\n"
"\t" ".set reg_x0, 0\n"
"\t" ".set reg_x1, 1\n"
"\t" ".set reg_x2, 2\n"
"\t" ".set reg_x3, 3\n"
"\t" ".set reg_x4, 4\n"
"\t" ".set reg_x5, 5\n"
"\t" ".set reg_x6, 6\n"
"\t" ".set reg_x7, 7\n"
"\t" "#crc32w %w0, %w1, %w2\n"
"\t" ".inst 0x1ac04800 | (reg_%2 << 16) | (reg_%1 << 5) | (reg_%0)\n"
: "=r"(res) : "r"(crc), "r"(val)
);
return res;
#else
volatile unsigned int res;
asm (".cpu generic+fp+simd+crc+crypto \n"
"crc32w %w0, %w1, %w2 \n"
: "=r"(res) : "r"(crc), "r"(val));
return res;
#endif
}
The second one commented out by the preprocessor block was suggested by Nick Clifton on the Binutils mailing list. The idea is GCC generates code using the ISA based on -march=XXX, so it does not matter if we increase capabilities to get past the assembler. We decided to go with Wang's answer because we did not want potential side effects from modifying the .cpu.
And the verification with GCC 4.8 and Binutils 2.24:
$ g++ -O1 test.cxx -c
$ objdump --disassemble test.o
test.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <main>:
0: 12001c01 and w1, w0, #0xff
4: 1ac14800 crc32w w0, w0, w1
8: d65f03c0 ret

zkcm configuration fails, can't find gmpxx.h

I'm trying to get zkcm up and running on my system (Mac OS X 10.11.3). I've installed gmp just fine (using ./configure --prefix=/usr/local --enable-cxx), and mpfr installed easily once I told it where to find gmp (/usr/local/include).
However, zkcm isn't installing as easily. It is also able to find the gmp.h file (using ./configure --with-gmp-include=/usr/local/include), but even though I can see gmpxx.h is right there, the configuration fails with
checking /usr/local/include/gmp.h usability... yes
checking /usr/local/include/gmp.h presence... yes
checking for /usr/local/include/gmp.h... yes
checking /usr/local/include/gmpxx.h usability... no
checking /usr/local/include/gmpxx.h presence... no
checking for /usr/local/include/gmpxx.h... no
configure: error: not found.
I'm not sure what the issue is. I've tried re-installing gmp several times, to no avail.
I've gone through other similar questions, but I could only find information directing me to what I've already done. I'm using the latest libraries for all three. How can I properly direct zkcm to gmpxx.h?
Edit
All of the config.log text with "gmpxx.h":
configure:3331: checking /usr/local/include/gmpxx.h usability
configure:3331: g++ -c -g -O2 conftest.cpp >&5
In file included from conftest.cpp:53:
/usr/local/include/gmpxx.h:43:10: error: 'gmp.h' file not found with <angled> include; use "quotes" instead
#include <gmp.h>
^~~~~~~
"gmp.h"
1 error generated.
configure:3331: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE__USR_LOCAL_INCLUDE_GMP_H 1
| /* end confdefs.h. */
| #include </usr/local/include/gmpxx.h>
configure:3331: result: no
configure:3331: checking for /usr/local/include/gmpxx.h
configure:3331: result: no
configure:3338: error: not found.

for XCode, default C++ language dialect?

In Xcode6, what's the "compiler default" for C++ language dialect.
I am using a C++ new feature std:max(a,b,c)
if I use "Compiler Default", it failed to compile.
When I changed to "C++11 or GNUC++11", it compiles fine.
I am wondering if compiler default is C++98?
I ran below code to get - GNU C++ 98.
#include <iostream>
int main()
{
//gnu mode
#ifndef __STRICT_ANSI__
std::cout << "GNU - ";
#endif
// C++ iso standard
#if __cplusplus == 199711L
std::cout << "C++98" << std::endl;
#elif __cplusplus == 201103L
std::cout << "C++11" << std::endl;
#elif __cplusplus > 201103L
std::cout << "C++14" << std::endl;
#endif
}
Macros chosen
__cplusplus - From gcc online documentation
Depending on the language standard selected, the value of the macro is
199711L, as mandated by the 1998 C++ standard; 201103L, per the 2011
C++ standard; an unspecified value strictly larger than 201103L for
the experimental languages enabled by -std=c++1y and -std=gnu++1y.
__STRICT_ANSI__ - From clang user manual
Differences between all c* and gnu* modes => c* modes define
__STRICT_ANSI__
As a side note, __STRICT_ANSI__ for GNU standard differentiation could also be found from this SO answer
$ g++ -E -dM -std=c++11 -x c++ /dev/null >b
$ g++ -E -dM -std=gnu++11 -x c++ /dev/null >a
$ diff -u a b
--- a 2014-12-19 12:27:11.000000000 +0530
+++ b 2014-12-19 12:27:05.000000000 +0530
## -144,6 +144,7 ##
#define __STDC_UTF_16__ 1
#define __STDC_UTF_32__ 1
#define __STDC__ 1
+#define __STRICT_ANSI__ 1
#define __UINTMAX_TYPE__ long unsigned int
#define __USER_LABEL_PREFIX__ _
#define __VERSION__ "4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)"

buildroot w/W11: error compiling eglibc

after configuring and running make goes
"make: * [/home/geekay/devel/buildroot/buildroot-2013.08.1/output/build/eglibc-2.17-svnr22064/.stamp_configured] Error 1"
cat output/build/eglibc-2.17-svnr22064/build/config.log command output
<...>
gcc version 4.8.1 (Buildroot 2013.08.1)
configure:2758: $? = 0
configure:2747: /home/geekay/devel/buildroot/buildroot-2013.08.1/output/host/usr/bin/arm-buildroot-linux-gnueabi-gcc -V >&5
arm-buildroot-linux-gnueabi-gcc: error: unrecognized command line option '-V'
arm-buildroot-linux-gnueabi-gcc: fatal error: no input files
compilation terminated.
configure:2758: $? = 1
configure:2747: /home/geekay/devel/buildroot/buildroot-2013.08.1/output/host/usr/bin/arm-buildroot-linux-gnueabi-gcc -qversion >&5
arm-buildroot-linux-gnueabi-gcc: error: unrecognized command line option '-qversion'
arm-buildroot-linux-gnueabi-gcc: fatal error: no input files
compilation terminated.
configure:2758: $? = 1
configure:2763: checking for suffix of object files
configure:2785: /home/geekay/devel/buildroot/buildroot-2013.08.1/output/host/usr/bin/arm-
buildroot-linux-gnueabi-gcc -c -O2 conftest.c >&5
Assembler messages:
Fatal error: invalid -march= option: `armv7-a'
configure:2789: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| #define PACKAGE_URL "http://www.gnu.org/software/glibc/"
| #define PKGVERSION "(Buildroot) "
| #define REPORT_BUGS_TO "<http://www.eglibc.org/issues/>"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:2803: error: in `/home/geekay/devel/buildroot/buildroot-2013.08.1/output/build/eglibc-2.17-svnr22064/build':
configure:2805: error: cannot compute suffix of object files: cannot compile
<...>
what do i need to tune and correct?

GCC compilation yields "real.h:53: error: 'SIZEOF_LONG' undeclared here (not in a function)"

I'm trying to compile GCC 4.7.2 on a Buffalo LinkStation Pro Duo (after unlocking it) which runs Linux 2.6.31.8 armv5tel.
Unfortunately, make throws quite some errors, starting with
gcc -c -DIN_GCC_FRONTEND -g -fkeep-inline-functions -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-formIn file included from ../../gcc-4.7.2/gcc/tree.h:32,
from ../../gcc-4.7.2/gcc/c-lang.c:27:
../../gcc-4.7.2/gcc/real.h:53: error: 'SIZEOF_LONG' undeclared here (not in a function)
In file included from ../../gcc-4.7.2/gcc/tree.h:32,
from ../../gcc-4.7.2/gcc/c-lang.c:27:
../../gcc-4.7.2/gcc/real.h:87:5: error: division by zero in #if
../../gcc-4.7.2/gcc/real.h:87:5: error: division by zero in #if
../../gcc-4.7.2/gcc/real.h:90:6: error: division by zero in #if
Line 53 of real.h reads unsigned long sig[SIGSZ];, where SIGSZ is defined at line 40 as
#define SIGSZ (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
while line 87 is #if REAL_WIDTH == 1 with REAL_WIDTH defined starting at line 72 as
#define REAL_WIDTH \
(REAL_VALUE_TYPE_SIZE/HOST_BITS_PER_WIDE_INT \
+ (REAL_VALUE_TYPE_SIZE%HOST_BITS_PER_WIDE_INT ? 1 : 0)) /* round up */
This seems to boil down to the HOST_BITS_PER_* being zero. Do I have to define these manually with some configure parameter or how can this issue be resolved?
update
config.log contains the following errors:
conftest.c:10:19: error: ppl_c.h: No such file or directory
conftest.c: In function 'main':
conftest.c:16: error: 'choke' undeclared (first use in this function)
conftest.c:16: error: (Each undeclared identifier is reported only once
conftest.c:16: error: for each function it appears in.)
conftest.c:16: error: expected ';' before 'me'
configure:5708: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h. */
| #include "ppl_c.h"
| int
| main ()
| {
|.
| #if PPL_VERSION_MAJOR != 0 || PPL_VERSION_MINOR < 11
| choke me
| #endif
|.
| ;
| r
Following this post I seem to have forgotten to install ppl, which I'll try now
SIZEOF_LONG should be #defined by configure in the file auto-host.h. Your auto-host.h should contain something like:
/* The size of `long', as computed by sizeof. */
#ifndef USED_FOR_TARGET
#define SIZEOF_LONG 8
#endif
If the above is not present (and it looks like in your case it's indeed so), check config.log for errors. Search for errors around the string checking size of long.
Thanks to chill's answer I checked config.log to discover
conftest.c:10:19: error: ppl_c.h: No such file or directory
(which, curiously, did not prevent configure from creating a Makefile and returning a success error code). The first google hit on that was this post, showing I didn't provide the ppl dependency.
The ppl-1.0 compilation greeted me with
checked_float.inlines.hh:1012: error: 'frexpl' was not declared in this scope
which led me to this post suggesting I'd use the 1.1 snapshot instead, which worked
Now, gcc's make offered me another "helpful" error:
gcc/../libcpp/include/line-map.h:66: error: 'CHAR_BIT'
which turned out to be due to C_INCLUDE_PATH ending with a colon (I already experienced the checking LIBRARY_PATH variable... contains current directory error mentioned in that post, but didn't think about checking other variables for that as well)
Compilation is still running, so far no more errors...

Resources