Bug: Duplicate symbols if there multiple source files have the same name
The compile() complains about duplicate symbols when there are multiple input files with the same name but in different directories. The cc names the object file by its source file and places them under OUT_DIR. It causes one object file to replace the other file, and pack the last object file twice in the .a static library.
This is an example of the occurrence. The target/debug/build/xxx/output log shows that two empty__functions.c files from different dirs are compiled into empty_functions.o in the same directory.
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/xxx/include" "-Wall" "-Wextra" "-o" "/my-crate/target/debug/build/rclrust-msg-ac6046ca5e70df07/out/empty__functions.o" "-c" "/xxx/include/std_msgs/msg/detail/empty__functions.c"
...
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "/xxx/include" "-Wall" "-Wextra" "-o" "/my-crate/target/debug/build/rclrust-msg-ac6046ca5e70df07/out/empty__functions.o" "-c" "/xxx/include/std_srvs/srv/detail/empty__functions.c"
...
Yeah... This happens if you specify source files by absolute path. Do you? If you specify them by relative path, then sub-directories will be reflected in -o arguments. One can argue if it's actually a bug or not. After all, the natural expectation would be that the common bias would be removed from the source files, but it's tricky to figure one out... Of course one can just as well say that it should graft absolute paths as if they were relative, but then you formally run higher risk of hitting some limit... Meanwhile it appears to be possible to env::set_current_dir(<your-absolute-path>) and then specify source files by relative path. "Appears to be possible" means that I did some quick testing and it worked, but didn't try to figure out if there are some pitfalls... set_currect_dir affects only the build script itself, and all other paths are absolute...
One can argue if it's actually a bug or not.
But just in case I've opened #684. You can test it by referring to cc as { git = "https://github.com/dot-asm/cc-rs", branch = "compiling-absolute-paths" } in your Cargo.toml.
I compiled *.c files in ROS directory /opt/ros/foxy directly. I tried to avoid writing C source code in my repository. That's why I passed absolute paths the cc. I prefer not to replace files with the same names or provide an option in cc to control the behavior.