Skip to content

Conversation

@vemakereporter
Copy link
Contributor

@vemakereporter vemakereporter commented Jul 25, 2019

Hi, I've fixed 47 missing dependencies and 51 excessive dependencies reported.
Those issues can cause incorrect results or unnecessary rebuilds when capstone is incrementally built.

For example, any changes in "arch/AArch64/AArch64BaseInfo.h" will not cause "arch/AArch64/AArch64BaseInfo.o" to be rebuilt, which is incorrect.

"MCInstrDesc.h" is specified as the prerequisite of "arch/Mips/MipsDisassembler.o". However, this header file is not read by the process when "arch/Mips/MipsDisassembler.o" is built. Hence, the changes in "MCInstrDesc.h" can cause an unnecessary rebuild of "arch/Mips/MipsDisassembler.o", which slow down the build of the whole project.

A useful tool is the -M class of flags that we can pass to clang/gcc to generate "dependency files". Even if we don't use the flag directly in the Makefile, a script that we use could take advantage of the feature.
I modify the Makefile to read dependencies from compiler-generated files. I've checked. The dependences generate from the new Makefile are correct.
Looking forward to your confirmation.

Thanks
Vemake

@vemakereporter vemakereporter changed the title Fixed 57 missing dependencies in Makefile Fixed 47 missing dependencies and 10 excessive dependencies in Makefile Jul 25, 2019
@vemakereporter
Copy link
Contributor Author

@aquynh @tmfink I have resubmitted the new PR to next track. Waiting for your confirmation.

@tmfink
Copy link
Contributor

tmfink commented Jul 26, 2019

@vemakereporter After doing a make and make clean, there are still *.d files in tests/ and suite/fuzz/.

$ make && make clean
$ find . -type f -name '*.d'
./tests/test_mos65xx.d
./tests/test_m68k.d
./tests/test_iter.d
./tests/test_systemz.d
./tests/test_arm.d
./tests/test_mips.d
./tests/test_evm.d
./tests/test_wasm.d
./tests/test_xcore.d
./tests/test_x86.d
./tests/test_skipdata.d
./tests/test_riscv.d
./tests/test_ppc.d
./tests/test_sparc.d
./tests/test_detail.d
./tests/test_basic.d
./tests/test_m680x.d
./tests/test_bpf.d
./tests/test_tms320c64x.d
./tests/test_arm64.d
./tests/test_customized_mnem.d
./suite/fuzz/drivermc.d
./suite/fuzz/fuzz_decode_platform.d
./suite/fuzz/fuzz_disasm.d
./suite/fuzz/driverbin.d
./suite/fuzz/platform.d

@tmfink
Copy link
Contributor

tmfink commented Jul 26, 2019

For tracking purposes, this is a follow-up to PR #1521 to the next branch.

@vemakereporter
Copy link
Contributor Author

@vemakereporter After doing a make and make clean, there are still *.d files in tests/ and suite/fuzz/.

$ make && make clean
$ find . -type f -name '*.d'
./tests/test_mos65xx.d
./tests/test_m68k.d
./tests/test_iter.d
./tests/test_systemz.d
./tests/test_arm.d
./tests/test_mips.d
./tests/test_evm.d
./tests/test_wasm.d
./tests/test_xcore.d
./tests/test_x86.d
./tests/test_skipdata.d
./tests/test_riscv.d
./tests/test_ppc.d
./tests/test_sparc.d
./tests/test_detail.d
./tests/test_basic.d
./tests/test_m680x.d
./tests/test_bpf.d
./tests/test_tms320c64x.d
./tests/test_arm64.d
./tests/test_customized_mnem.d
./suite/fuzz/drivermc.d
./suite/fuzz/fuzz_decode_platform.d
./suite/fuzz/fuzz_disasm.d
./suite/fuzz/driverbin.d
./suite/fuzz/platform.d

test and suite/fuzz have their separate Makefiles. I include a removal command in their clean targets too.

@vemakereporter
Copy link
Contributor Author

@tmfink @aquynh


clean:
rm -rf fuzz_harness $(OBJS) $(PLATFORMDECODE) $(REPRODUCERMC) $(REPRODUCERBIN) $(FUZZERBIN) $(OBJDIR)/lib$(LIBNAME).* $(OBJDIR)/$(LIBNAME).*
rm -rf *.d $(OBJDIR)/*.d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you want the '-r' day here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right

tests/Makefile Outdated

clean:
rm -rf $(OBJS) $(BINARY) $(TESTDIR)/*.exe $(TESTDIR)/*.static $(OBJDIR)/lib$(LIBNAME).* $(OBJDIR)/$(LIBNAME).*
rm -rf *.d $(TESTDIR)/*.d $(OBJDIR)/*.d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.

@vemakereporter
Copy link
Contributor Author

@tmfink @aquynh Is it okay?

@vemakereporter vemakereporter changed the title Fixed 47 missing dependencies and 10 excessive dependencies in Makefile Fixed 47 missing dependencies and 51 excessive dependencies in Makefile Jul 26, 2019
@vemakereporter
Copy link
Contributor Author

@tmfink @aquynh We have tested the project again, and found that these header files cause 51 excessive dependencies in total, which cause unnecessary incremental rebuilds of 51 targets including "arch/Mips/MipsDisassembler.o". Looking forward to your confirmation.

cstool/Makefile Outdated

clean:
${RM} -rf *.o $(TARGET)
${RM} -rf *.d
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no more .o files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it just creates .d files aside to the .o files.

@vemakereporter
Copy link
Contributor Author

@tmfink @aquynh We have fixed it.

@aquynh
Copy link
Collaborator

aquynh commented Jul 29, 2019

cool, just 1 minor issue now: we have a conflict in Makefile, so i cannot merge. could you please fix it?

@vemakereporter
Copy link
Contributor Author

cool, just 1 minor issue now: we have a conflict in Makefile, so i cannot merge. could you please fix it?

Conflict resolved.

@aquynh aquynh merged commit eb35714 into capstone-engine:next Jul 29, 2019
@aquynh
Copy link
Collaborator

aquynh commented Jul 29, 2019

merged, thanks!

@riptl riptl mentioned this pull request Jul 22, 2022
6 tasks
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

Successfully merging this pull request may close these issues.

3 participants