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

Can't build code on Ubuntu 18.04 #46

Open
anirudhSK opened this issue Dec 22, 2019 · 5 comments
Open

Can't build code on Ubuntu 18.04 #46

anirudhSK opened this issue Dec 22, 2019 · 5 comments

Comments

@anirudhSK
Copy link
Collaborator

I tried building the code on my Ubuntu 18.04 machine after running apt-get install libz3-dev. Here's the error log:

make
g++ -D_MP_INTERNAL -DNDEBUG -D_EXTERNAL_RELEASE -std=c++11 -fvisibility=hidden -c -mfpmath=sse -msse -msse2 -O3 -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value -fPIC -o main_z3.o -I../z3/src/api -I../z3/src/api/c++ main.cc
In file included from measure/common.h:5:0,
from main.cc:12:
measure/../inst.h:40:19: error: expected identifier before numeric constant
#define NUM_INSTR 12
^
measure/../inst.h:99:4: note: in expansion of macro ‘NUM_INSTR’
[NUM_INSTR ... 255] = UNUSED_OPS,
^~~~~~~~~
measure/../inst.h: In lambda function:
measure/../inst.h:99:23: error: expected ‘{’ before ‘=’ token
[NUM_INSTR ... 255] = UNUSED_OPS,
^
measure/../inst.h: At global scope:
measure/../inst.h:84:75: error: no match for ‘operator=’ (operand types are ‘<lambda()>’ and ‘int’)
#define UNUSED_OPS (FSTOP(OP_UNUSED) | SNDOP(OP_UNUSED) | TRDOP(OP_UNUSED))
^
measure/../inst.h:99:25: note: in expansion of macro ‘UNUSED_OPS’
[NUM_INSTR ... 255] = UNUSED_OPS,
^~~~~~~~~~
measure/../inst.h:99:21: note: candidate: <lambda()>&<lambda()>::operator=(const<lambda()>&)
[NUM_INSTR ... 255] = UNUSED_OPS,
^
measure/../inst.h:99:21: note: no known conversion for argument 1 from ‘int’ to ‘const<lambda()>&’
measure/../inst.h:40:19: error: expected identifier before numeric constant
#define NUM_INSTR 12
^
measure/../inst.h:115:4: note: in expansion of macro ‘NUM_INSTR’
[NUM_INSTR ... 255] = 0,
^~~~~~~~~
measure/../inst.h: In lambda function:
measure/../inst.h:115:23: error: expected ‘{’ before ‘=’ token
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h: At global scope:
measure/../inst.h:115:25: error: no match for ‘operator=’ (operand types are ‘<lambda()>’ and ‘int’)
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h:115:21: note: candidate: <lambda()>&<lambda()>::operator=(const<lambda()>&)
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h:115:21: note: no known conversion for argument 1 from ‘int’ to ‘const<lambda()>&’
measure/../inst.h:40:19: error: expected identifier before numeric constant
#define NUM_INSTR 12
^
measure/../inst.h:131:4: note: in expansion of macro ‘NUM_INSTR’
[NUM_INSTR ... 255] = 0,
^~~~~~~~~
measure/../inst.h: In lambda function:
measure/../inst.h:131:23: error: expected ‘{’ before ‘=’ token
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h: At global scope:
measure/../inst.h:131:25: error: no match for ‘operator=’ (operand types are ‘<lambda()>’ and ‘int’)
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h:131:21: note: candidate: <lambda()>&<lambda()>::operator=(const<lambda()>&)
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h:131:21: note: no known conversion for argument 1 from ‘int’ to ‘const<lambda()>&’
measure/../inst.h:40:19: error: expected identifier before numeric constant
#define NUM_INSTR 12
^
measure/../inst.h:147:4: note: in expansion of macro ‘NUM_INSTR’
[NUM_INSTR ... 255] = 0,
^~~~~~~~~
measure/../inst.h: In lambda function:
measure/../inst.h:147:23: error: expected ‘{’ before ‘=’ token
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h: At global scope:
measure/../inst.h:147:25: error: no match for ‘operator=’ (operand types are ‘<lambda()>’ and ‘int’)
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h:147:21: note: candidate: <lambda()>&<lambda()>::operator=(const<lambda()>&)
[NUM_INSTR ... 255] = 0,
^
measure/../inst.h:147:21: note: no known conversion for argument 1 from ‘int’ to ‘const<lambda()>&’
Makefile:7: recipe for target 'main_z3.o' failed
make: *** [main_z3.o] Error 1

The g++ version is 7.4.0. I also tried std=c++14 and std=c++17, but I get the same error.

@anirudhSK anirudhSK changed the title Trouble building code Can't build code on Ubuntu 18.04 Dec 22, 2019
@QiongwenXu
Copy link
Collaborator

I will fix it soon. The following is the reason why code cannot be built on Ubuntu.

[NUM_INSTR ... 255] = 0,

is a designated initializer usage which is not supported in g++

In ISO C99 you can give the elements in any order, specifying the array indices or structure field names they apply to, and GNU C allows this as an extension in C90 mode as well. This extension is not implemented in GNU C++.

reference: https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

I implemented the code in Mac OS, and the reason why it works it that when g++ cmd is executed, actually g++ is linked to xcode's clang

xuqiongwendeMacBook-Pro:bin xuqiongwen$ g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

This was referenced Dec 24, 2019
@ngsrinivas
Copy link
Collaborator

@QiongwenXu am I correct that the issue is fixed? (I'm yet to check on ubuntu) Please merge everything into master. Once both are done, you could ping @anirudhSK to re-try the build.

@QiongwenXu
Copy link
Collaborator

QiongwenXu commented Jan 10, 2020

@anirudhSK The issue has been addressed in master. Could you please rebuild the latest code?

@anirudhSK
Copy link
Collaborator Author

anirudhSK commented Jan 11, 2020

I now get:

Makefile:1: ../z3/build/config.mk: No such file or directory
make: *** No rule to make target '../z3/build/config.mk'. Stop.

The first line in the Makefile "include ../z3/build/config.mk" seems to assume that z3 sources (not just libraries) are available on the system. Maybe we should add the exact dependence on z3 to a README?

@QiongwenXu
Copy link
Collaborator

QiongwenXu commented Jan 11, 2020

I now get:

Makefile:1: ../z3/build/config.mk: No such file or directory
make: *** No rule to make target '../z3/build/config.mk'. Stop.

The first line in the Makefile "include ../z3/build/config.mk" seems to assume that z3 sources (not just libraries) are available on the system. Maybe we should add the exact dependence on z3 to a README?

@anirudhSK

Yes, also the path of z3 folder is fixed to superopt folder

Could you please try this
install z3 (more in https://github.com/Z3Prover/z3)

git clone https://github.com/Z3Prover/z3.git
cd z3
python scripts/mk_make.py
cd build
make
sudo make install

install superopt
keep folder superopt and z3 in the same directory level

cd ../../
git clone https://github.com/ngsrinivas/superopt.git
cd superopt
make main.out

Then you can use

./main.out -h 

to show usage. There is also an example in measure/meas_mh_bhv_script.sh.

I will add these into README soon: https://github.com/ngsrinivas/superopt/blob/readme/README.md

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

3 participants