Clang - invalid type for value - clang

I tried running clang -S -emit-llvm test.bc and I got this error: Invalid type for value. Does anyone know what does that mean? I get the same error when running llvm-dis.

This happens when the version of opt that was used to produce the bitcode is different from the clang that you are giving bitcode to.
Assert that version of clang >= version of opt.

Related

I'm getting an error "Undefined symbols for architecture x86_64" and can't find the error in compilation

This is what my files look like
My main function is here
I compiled it using the following command:
g++ -std=c++17 main.cpp linkedList.cpp -o main
on MacOS 10.14 using the latest gcc compiler as of 2018.
It looks like the definitions for your template are not visible to the compiler when it is instantiated. You need to move the definitions from linkedList.cpp into the header file, linkedList.hpp.
(Note that C++17 support is still experimental in GCC.)

XlC flag qhalt issue

I'm using xlC 13.1.5 and CMake 3.5. When I try to compile an MPI package using CMake, I get the following error:
/opt/ibm/xlC/13.1.5/bin/.orig/xlc_r: warning: 1501-269 fpic is not supported on this Operating System platform. Option fpic will be ignored.
error: 1540-5203 Unrecognized value "e" specified with option "halt".
1 error generated.
I read it is a bug of this compiler version, that adding qhalt flag with "e" option is not supported. Is there a workaround to solve the problem? At the moment I can't change compiler version.
-qhalt=e is from an older compiler version, only -qhalt=w is supported on 13.1.5
When I try it I get a warning instead of an error
xlC -qhalt=w -c b1.cpp
xlC -qhalt=e -c b1.cpp
warning: 1540-5203 Unrecognized value "e" specified with option "halt".
1 warning generated.``
I'm assuming the option is in the makefile for your project which might be setup for the older xlC releases that accept the option. Can you update it in the makefile?
-qhalt=w just get's transformed to -Werror and sent to clang on 13.1.5

Error compiling Mosquitto 1.4

I have tried to compile Mosquitto on both Arch and CentOS 7, but everytime I get the same error. I want to test the Websocket feature.
This is the procedure I am using for CentOS:
yum group install "Development Tools"
yum install cmake openssl-devel cmake
yum install uuid-devel libxslt docbook5-style-xsl.noarch docbook-style-xsl.noarch
git clone https://github.com/warmcat/libwebsockets.git
cd libwebsockets/
mkdir build;cd build
cmake ..
make
make install
git clone https://git.eclipse.org/r/mosquitto/org.eclipse.mosquitto
cd org.eclipse.mosquitto/
git checkout origin/1.4
vi config.mk
Change "WITH_WEBSOCKETS:=yes"
make
And this is where it dies on Arch and CentOS:
make[1]: Entering directory '/home/install/org.eclipse.mosquitto/src'
cc -Wall -ggdb -O2 -I. -I.. -I../lib -DVERSION="\"1.4\"" -DTIMESTAMP="\"2015-05-04 17:17:55+0200\"" -DWITH_BROKER -DWITH_TLS -DWITH_TLS_PSK -DWITH_UUID -DWITH_BRIDGE -DWITH_PERSISTENCE -DWITH_MEMORY_TRACKING -DWITH_SYS_TREE -DWITH_WEBSOCKETS -DWITH_EC -c mosquitto.c -o mosquitto.o
In file included from /usr/include/unistd.h:25:0,
from mosquitto.c:22:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
mosquitto.c: In function ‘main’:
mosquitto.c:275:101: error: expected expression before ‘,’ token
_mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "mosquitto version %s (build date %s) starting", VERSION, TIMESTAMP);
mosquitto.c:290:54: error: expected expression before ‘)’ token
snprintf(buf, 1024, "mosquitto version %s", VERSION);
mosquitto.c:368:88: error: expected expression before ‘)’ token
_mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "mosquitto version %s terminating", VERSION);
Makefile:15: recipe for target 'mosquitto.o' failed
make[1]: *** [mosquitto.o] Error 1
make[1]: Leaving directory '/home/install/org.eclipse.mosquitto/src'
Makefile:21: recipe for target 'mosquitto' failed
make: *** [mosquitto] Error 2
If someone can please point out what I am doing wrong or missing ?
As #hardillb says, the VERSION defines are the problem. If I add the line
#define VERSION
to mosquitto.c, then I can reproduce the error that you see, but also get a warning about redefining VERSION.
If I remove the definition of VERSION from config.mk, then I get an error about VERSION not being defined.
These both make sense.
What seems to be happening for you is that the compiler is ignoring the command line definition -DVERSION="\"1.4.1\"" and replacing it with -DVERSION=, or isn't parsing the string properly. This doesn't make sense.
Other people have managed to compile on Arch, and the CentOS7 repository has a binary version - but without websockets.
After some investigation, it appears as though there is a bug in recent libwebsockets code. This changeset introduces some changes that mean that libwebsockets is claiming the macro VERSION all for itself, which isn't very polite for a library. If you use a released version of libwebsockets you should not have any problem compiling.
Just out of interest have you tried building from the TGZ src bundle for Mosquitto 1.4.1 available here:
http://mosquitto.org/download/
The errors look to be something to do with expanding the passed in VERSION and TIMESTAMP values. It builds fine [with the exception of the docs] on Fedora 20 which shouldn't be that far from RHEL 7.0 (and from there to Centos 7).

Error Cross Compiling: hidden symbol ... final link failed

I am getting the following error when compiling opencv with ffmpeg.
..../arm-none-linux-gnueabi/bin/ld: ../../bin/opencv_test_core: hidden symbol `__sync_val_compare_and_swap_4' in ..../arm-none-linux-gnueabi/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
I have no idea what this means. How do I fix this?
Edit:
I am cross compiling for ARM using codesourcery's arm-2009q3 compiler.
I using cmake and make to compile.
Please check all the libraries that you use and go through this stackoverflow thread as well.
To me, I got the below error when I migrated my product to new GCC version (3.3.3 to 4.5.4)
hidden symbol `__clz_tab' in /../lib/gcc/mipsel-unknown-linux-uclibc/4.5.4/libgcc.a(_clz.o) is referenced by DSO
Later I found that one of the library that I tried to link was built using GCC 3.3.3. After building the other library under GCC 4.5.4, the 'hidden symbol' error disappeared.

How to avoid error of stdio.h while using a clang checker on a file which includes stdio.h file

I have implemented a checker in clang. I have compiled it and now i am using it to check on a c file which includes stdio.h file. I am giving below command to run the checker :
clang -cc1 -analyze -analyzer-checker=alpha.core.FuncPrototype funcprototypetest.c
I am getting below error :
funcprototypetest.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^
Can anybody help me with a proper way to handle this error.When i compile the funcprototype.c file independently with gcc, it gets compiled. So i am not getting what can be the issue?
Thanks in advance.
Answer found here: http://permalink.gmane.org/gmane.comp.compilers.clang.devel/37462
You mast use
clang --analyze -Xclang -analyzer-checker=alpha.core.FuncPrototype funcprototypetest.c
instead
clang -cc1 -analyze -analyzer-checker=alpha.core.FuncPrototype funcprototypetest.c

Resources