s2e-env icon indicating copy to clipboard operation
s2e-env copied to clipboard

makefile: list target may not work on non-english setups

Open cxm95 opened this issue 7 years ago • 10 comments

Hi, when I want to compile a plugin, the s2e command not working.

I installed the s2e using s2e-env.

(venv) ➜  s2e-proj s2e build --rebuild-components libs2e
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/xxx/s2e-proj/build/s2e --file=/home/xxx/s2e-proj/source/s2e/Makefile list'>: starting process
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/xxx/s2e-proj/build/s2e --file=/home/xxx/s2e-proj/source/s2e/Makefile list', pid 87347>: process started
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/xxx/s2e-proj/build/s2e --file=/home/cxm/xxx/source/s2e/Makefile list', pid 87347>: process completed
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/xxx/s2e-proj/build/s2e --file=/home/cxm/xxx/source/s2e/Makefile list', pid 87347>: process completed
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/xxx/s2e-proj/build/s2e --file=/home/cxm/xxx/s2e-proj/source/s2e/Makefile list', pid 87347>: process completed
ERROR: [build] Component libs2e is not valid. Valid components are: 

BTW, when I use s2e build, the s2e-env downloaded some binaries from github then show me that build success, without compiling any of the components.

Looking forward to your reply!

cxm95 avatar Nov 27 '17 11:11 cxm95

Hmmm that's strange, is that the end of the entire message? The valid components list is empty?

adrianherrera avatar Nov 27 '17 11:11 adrianherrera

Yeah, that's the end. However, yesterday I tried s2e build command, and it worked properly (compiled all the components).

cxm95 avatar Nov 27 '17 11:11 cxm95

Ok, that’s very very strange. I will have a closer look at the s2e-env command and make file to see if there is anything obvious.

If you just run “s2e build -r hdidhjedh” or some other random gibberish does it produce the same error message? On Mon, 27 Nov 2017 at 10:57 pm, cxm1995 [email protected] wrote:

Yeah, that's the end. However, yesterday I tried s2e build command, and it worked properly (compiled all the components).

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/S2E/s2e-env/issues/69#issuecomment-347161132, or mute the thread https://github.com/notifications/unsubscribe-auth/AIOhksa7mqZMGm-E_ASoZZeOrtzU6pxhks5s6qOugaJpZM4QrhDj .

adrianherrera avatar Nov 27 '17 12:11 adrianherrera

Yes, the same error message.

(venv) ➜  s2e-proj s2e build -r asdfasdfasdf
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/cxm/Dev_Playground/s2e-proj/build/s2e --file=/home/cxm/Dev_Playground/s2e-proj/source/s2e/Makefile list'>: starting process
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/cxm/Dev_Playground/s2e-proj/build/s2e --file=/home/cxm/Dev_Playground/s2e-proj/source/s2e/Makefile list', pid 88077>: process started
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/cxm/Dev_Playground/s2e-proj/build/s2e --file=/home/cxm/Dev_Playground/s2e-proj/source/s2e/Makefile list', pid 88077>: process completed
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/cxm/Dev_Playground/s2e-proj/build/s2e --file=/home/cxm/Dev_Playground/s2e-proj/source/s2e/Makefile list', pid 88077>: process completed
INFO: [sh.command] <Command u'/usr/bin/make --directory=/home/cxm/Dev_Playground/s2e-proj/build/s2e --file=/home/cxm/Dev_Playground/s2e-proj/source/s2e/Makefile list', pid 88077>: process completed
ERROR: [build] Component libs2e is not valid. Valid components are:
(venv) ➜

( Previous paths are manually modified )

cxm95 avatar Nov 27 '17 12:11 cxm95

What is the output of this command?

make -f $S2E/source/s2e/build-scripts/Makefile list

You should see all the build targets for S2E, i.e.:

all all-debug all-release ALWAYS cfe-3.9.0.src cfe-3.9.0.src.tar.xz clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04 clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz clean compiler-rt-3.9.0.src compiler-rt-3.9.0.src.tar.xz decree distclean
<snip>

The s2e-env build command then reads this output to decide what are valid rebuild targets. Do you get similar output?

adrianherrera avatar Nov 28 '17 04:11 adrianherrera

Sadly, the output is nothing.

Are there any environment variable that must be set during the compilation, like $S2E?

(venv) ➜  s2e-proj echo $S2E
/home/cxm/Dev_Playground/s2e-proj/
(venv) ➜  s2e-proj make -f $S2E/source/s2e/build-scripts/Makefile list

(venv) ➜  s2e-proj 

cxm95 avatar Nov 28 '17 08:11 cxm95

Weird. I would investigate why this isn't working. Maybe you have old version of make or something? The list command comes from the accepted solution at https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile

adrianherrera avatar Nov 29 '17 00:11 adrianherrera

I finally got the reason with the help of my teammate.

When I run the build command, we noticed that -pRrq is used to get current make status.

# From https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile
list:
	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null |                                  \
		awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | \
		sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs

.PHONY: all all-debug all-release
.PHONY: clean distclean guestclean
.PHONY: list

https://github.com/S2E/build-scripts/blob/52bad1e01629ee7f4197264ae8aa466d7240c220/Makefile#L139

However, I installed the ubuntu using Chinese, so some output of the -pRrq option is in Chinese.

make -pRrq -f ../Makefile 
# GNU Make 4.2
# 为 x86_64-pc-linux-gnu 编译
# Copyright (C) 1988-2016 Free Software Foundation, Inc.
# 许可证:GPLv3+:GNU 通用公共许可证第 3 版或更新版本<http://gnu.org/licenses/gpl.html>。
# 本软件是自由软件:您可以自由修改和重新发布它。
# 在法律允许的范围内没有其他保证。

# make 数据基础,打印在 Wed Dec 13 17:23:29 2017
......

So awk, sort and other commands may not work properly.

Maybe you can rewrite this snippet in a robust way.

Thanks!

cxm95 avatar Dec 13 '17 13:12 cxm95

Thanks for the detailed report! Since you experienced the bug and can reproduce it reliably, I believe you would be in the best position to rewrite it. We'd be happy to review and test the patch.

vitalych avatar Dec 13 '17 14:12 vitalych

list: @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null |
awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' |
sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs

$(lastword) return the last one of the $(MAKEFILE_LIST), but it isn't accurate. it should be replaced according to your situation.

Pai-Po avatar Aug 13 '20 09:08 Pai-Po