-
Notifications
You must be signed in to change notification settings - Fork 34
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
Compilation fails due to files given multiple times as arguments to the compiler - CppLibrary::vendor_bundle?
is hardcoded, not $BUNDLE_PATH
#69
Comments
This seems like a strange bug, since the file list is taken from 3 places that should not overlap. Can you try this patch? It should add some harmless command line options to break up the file listing and hopefully help isolate the code that's creating those duplicate entries:
|
With that patch the last command becomes: Last
command:
$
g++
-std=c++0x
-o
/tmp/dummy2/unittest_dummy.cpp.bin
-DARDUINO=100
-D__AVR_ATmega328P__
-I/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino
-I/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/unittest
-I/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino
-I/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/avr
-I/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/ci
-I/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/unittest
-DARDUINO_CI_cpp_files_arduino
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/Arduino.cpp
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/Godmode.cpp
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/stdlib.cpp
-DARDUINO_CI_cpp_files_unittest
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/unittest/ArduinoUnitTests.cpp
-DARDUINO_CI_cpp_files
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/Arduino.cpp
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/Godmode.cpp
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/arduino/stdlib.cpp
/tmp/dummy2/bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/cpp/unittest/ArduinoUnitTests.cpp
/tmp/dummy2/test/dummy.cpp |
When retesting the minimum scenario today https://github.com/ianfixes/arduino_ci/issues/69#issuecomment-457851016 I used just gem install bundler and there were no problems like there had been earlier. So things have apparently been resolved and the version specific install workaround is no longer needed. I tested using a separate user starting with an empty home directory, e.g. guarantied no old stale things being picked up.
When retesting the minimum scenario today https://github.com/ianfixes/arduino_ci/issues/69#issuecomment-457851016 I used just gem install bundler and there were no problems like there had been earlier. So things have apparently been resolved and the version specific install workaround is no longer needed. I tested using a separate user starting with an empty home directory, e.g. guaranteed no old stale things being picked up.
Aah interesting. I was in the middle of writing a long comment about how I couldn't figure out the problem but it just jumped out at me. If I'm reading this correctly, your library is installed at /tmp/dummy2 and the directory of gem dependencies happens to live inside it. So I would have thought the bundle stuff would go into I'm going to have to fix |
CppLibrary::vendor_bundle?
is hardcoded, not $BUNDLE_PATH
I can confirm that this solves the issue reported. With all the commands like previously, plus: git clone https://github.com/ianfixes/arduino_ci/
cd arduino_ci/
git checkout 2019-01-28_skip_ci
cd ..
cp arduino_ci/lib/arduino_ci/* bundle_install/ruby/2.5.0/gems/arduino_ci-0.1.17/lib/arduino_ci/.
rm -rf arduino_ci/
mkdir -p examples/dummy
cp dummy.ino examples/dummy/.
bundle exec arduino_ci_remote.rb this results in Unit testing dummy.cpp with g++...
TAP version 13
1..1
# Subtest: dummy_test
ok 1 - assertEqual 4 == 4
1..1
ok 1 - dummy_test
...Unit testing dummy.cpp with g++ ✓
Indexing libraries... ✓
Installing library under test... ✓
Library installed at... /home/download/Arduino/libraries/dummy
example_path = /home/download/Arduino/libraries/dummy/examples
examples = ["dummy"]
proj_file = /home/download/Arduino/libraries/dummy/examples/dummy/dummy.ino
Requested library example platform 'uno' is defined in 'platforms' YML... ✓
Using built-in board package... arduino:avr
Installing board package arduino:avr... ✓
Setting compiler warning level... ✓
Switching to board for uno (arduino:avr:uno)... ✓
Verifying dummy.ino... ✓
Failures: 0 |
Hm, while the change did fix the minimal example reported above which I tested, it breaks when I try to update my main project to 0.1.18. I bisected the change to be this Forcing a print of the last command regardless of failure gives an opportunity to make a diff of the successful case using the parent commit of g++
-std=c++0x
-o
/share/hlovdal/arduino/sketchbook/proj1/unittest_cust_char_tests.cpp.bin
-DARDUINO=100
-D__AVR_ATmega328P__
-I/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/arduino
-I/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/unittest
--I/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/arduino/avr
--I/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/arduino/ci
--I/share/hlovdal/arduino/sketchbook/proj1/src
-I/share/hlovdal/arduino/sketchbook/libraries/SmartLCD
-DARDUINO_CI_cpp_files_arduino
/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/arduino/Arduino.cpp
/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/arduino/Godmode.cpp
/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/arduino/stdlib.cpp
-DARDUINO_CI_cpp_files_unittest
/share/hlovdal/arduino/sketchbook/proj1/arduino_ci/cpp/unittest/ArduinoUnitTests.cpp
-DARDUINO_CI_cpp_files
-/share/hlovdal/arduino/sketchbook/proj1/src/proj1_keys.cpp
-/share/hlovdal/arduino/sketchbook/proj1/src/proj1_lcd.cpp
-/share/hlovdal/arduino/sketchbook/proj1/src/cust_char.cpp
-DUNIT_TEST
-g
/share/hlovdal/arduino/sketchbook/libraries/SmartLCD/SmartLCDI2C.cpp
/share/hlovdal/arduino/sketchbook/proj1/test/cust_char_tests.cpp |
Full compile output (filtered though the
|
With the following debug changes: commit 30a5b0b9ec845f43dc5b232a8f703b0686e2ea09
Author: Håkon Løvdal <kode@denkule.no>
Date: Wed Jan 30 22:21:18 2019 +0100
debug
diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb
index dbff893..5ce59a0 100644
--- a/lib/arduino_ci/cpp_library.rb
+++ b/lib/arduino_ci/cpp_library.rb
@@ -58,6 +58,7 @@ module ArduinoCI
return false unless base.exist?
vendor_bundle_aliases = [base, base.realpath]
+ puts "vendor_bundle_aliases = #{vendor_bundle_aliases}"
# we could do this but some rubies don't return an enumerator for ascend
# path.ascend.any? { |part| vendor_bundle_aliases.include?(part) }
@@ -117,6 +118,10 @@ module ArduinoCI
# @return [Array<Pathname>]
def cpp_files
puts "@base_dir = #{@base_dir}"
+ all = cpp_files_in(@base_dir)
+ puts "all = #{all}"
+ v = cpp_files_in(@base_dir).reject { |p| vendor_bundle?(p) }
+ puts "v = #{v}"
cpp_files_in(@base_dir).reject { |p| vendor_bundle?(p) || in_tests_dir?(p) }
end
commit 7b527931d6219185fef51d4e7843b4a8dfee7f62
Author: Håkon Løvdal <kode@denkule.no>
Date: Sun Jan 27 15:05:35 2019 +0100
Issue 96 more debug
diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb
index 19d8889..dbff893 100644
--- a/lib/arduino_ci/cpp_library.rb
+++ b/lib/arduino_ci/cpp_library.rb
@@ -116,18 +116,21 @@ module ArduinoCI
# CPP files that are part of the project library under test
# @return [Array<Pathname>]
def cpp_files
+ puts "@base_dir = #{@base_dir}"
cpp_files_in(@base_dir).reject { |p| vendor_bundle?(p) || in_tests_dir?(p) }
end
# CPP files that are part of the arduino mock library we're providing
# @return [Array<Pathname>]
def cpp_files_arduino
+ puts "ARDUINO_HEADER_DIR = #{ARDUINO_HEADER_DIR}"
cpp_files_in(ARDUINO_HEADER_DIR)
end
# CPP files that are part of the unit test library we're providing
# @return [Array<Pathname>]
def cpp_files_unittest
+ puts "UNITTEST_HEADER_DIR = #{UNITTEST_HEADER_DIR}"
cpp_files_in(UNITTEST_HEADER_DIR)
end
commit 8f5fdbe07fac6a8f1d28f574134c38a46c93b60e
Author: Håkon Løvdal <kode@denkule.no>
Date: Sun Jan 27 15:04:39 2019 +0100
Issue 69 debug
https://github.com/ianfixes/arduino_ci/issues/69#issuecomment-450652373
diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb
index f6f5833..19d8889 100644
--- a/lib/arduino_ci/cpp_library.rb
+++ b/lib/arduino_ci/cpp_library.rb
@@ -243,8 +243,11 @@ module ArduinoCI
def test_args(aux_libraries, ci_gcc_config)
# TODO: something with libraries?
ret = include_args(aux_libraries)
+ ret += ["-DARDUINO_CI_cpp_files_arduino"]
ret += cpp_files_arduino.map(&:to_s)
+ ret += ["-DARDUINO_CI_cpp_files_unittest"]
ret += cpp_files_unittest.map(&:to_s)
+ ret += ["-DARDUINO_CI_cpp_files"]
ret += cpp_files.map(&:to_s)
unless ci_gcc_config.nil?
cgc = ci_gcc_config
|
Most recent gem is Can you give me more hints on how to reproduce this behavior locally? I did the debug in a slightly different way, which you might prefer -- it embeds the path (and "real path", if symlinked) into the build args: diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb
index f6f5833..19d8889 100644
--- a/lib/arduino_ci/cpp_library.rb
+++ b/lib/arduino_ci/cpp_library.rb
@@ -243,8 +243,11 @@ module ArduinoCI
def test_args(aux_libraries, ci_gcc_config)
# TODO: something with libraries?
ret = include_args(aux_libraries)
+ ret << "-DARDUINO_CI_cpp_files_arduino=#{ARDUINO_HEADER_DIR}:#{ARDUINO_HEADER_DIR.realpath}"
ret += cpp_files_arduino.map(&:to_s)
+ ret << "-DARDUINO_CI_cpp_files_unittest=#{UNITTEST_HEADER_DIR}:#{UNITTEST_HEADER_DIR.realpath}"
ret += cpp_files_unittest.map(&:to_s)
+ ret << "-DARDUINO_CI_cpp_files=#{@base_dir}:#{@base_dir.realpath}"
ret += cpp_files.map(&:to_s)
unless ci_gcc_config.nil?
cgc = ci_gcc_config |
No, I am saying it stops working in 90b3e68 and from then on. The newer code is much better at excluding itself, before I had to Here is a minimal example to reproduce (this time with paste friendly commands): mkdir /tmp/compiletest
cd /tmp/compiletest
cat > .arduino-ci.yaml << EOF
compile:
libraries: ~
platforms:
- uno
unittest:
libraries: ~
platforms:
- uno
EOF
cat > Gemfile << EOF
source 'https://rubygems.org'
gem 'arduino_ci', :path => "arduino_ci"
EOF
mkdir src
echo 'bool greater_than_five(int n);' > src/five.hpp
cat > src/five.cpp << EOF
#include "five.hpp"
bool greater_than_five(int n) {
return n > 5;
}
EOF
mkdir test
cat > test/five_tests.cpp << EOF
#include <ArduinoUnitTests.h>
#include "../src/five.hpp"
unittest(one)
{
assertFalse(greater_than_five(1));
}
unittest(ten)
{
assertTrue(greater_than_five(10));
}
unittest_main()
EOF
git clone https://github.com/ianfixes/arduino_ci
cd arduino_ci
git am .../debug.patch # https://github.com/ianfixes/arduino_ci/issues/69#issuecomment-459180028
cd ..
bundle install --path vendor/bundle
bundle exec arduino_ci_remote.rb --skip-compilation which produces The set of compilers (1) isn't empty... ✓
Checking g++ version...
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.2.1 20181215 (Red Hat 8.2.1-6) (GCC)
...Checking g++ version ✓
libasan availability for g++... false
Requested unittest platform 'uno' is defined in 'platforms' YML... ✓
Unit testing five_tests.cpp with g++...
Last command: $ g++ -std=c++0x -o /tmp/compiletest/unittest_five_tests.cpp.bin -DARDUINO=100
-D__AVR_ATmega328P__ -I/tmp/compiletest/arduino_ci/cpp/arduino -I/tmp/compiletest/arduino_ci/cpp/unittest
-DARDUINO_CI_cpp_files_arduino=/tmp/compiletest/arduino_ci/cpp/arduino:/tmp/compiletest/arduino_ci/cpp/arduino /tmp/compiletest/arduino_ci/cpp/arduino/Arduino.cpp /tmp/compiletest/arduino_ci/cpp/arduino/Godmode.cpp /tmp/compiletest/arduino_ci/cpp/arduino/stdlib.cpp
-DARDUINO_CI_cpp_files_unittest=/tmp/compiletest/arduino_ci/cpp/unittest:/tmp/compiletest/arduino_ci/cpp/unittest /tmp/compiletest/arduino_ci/cpp/unittest/ArduinoUnitTests.cpp
-DARDUINO_CI_cpp_files=.:/tmp/compiletest /tmp/compiletest/test/five_tests.cpp
/usr/bin/ld: /tmp/cctXTkoJ.o: in function `test_one::task()':
five_tests.cpp:(.text+0x17): undefined reference to `greater_than_five(int)'
/usr/bin/ld: /tmp/cctXTkoJ.o: in function `test_ten::task()':
five_tests.cpp:(.text+0x85): undefined reference to `greater_than_five(int)'
collect2: error: ld returned 1 exit status
...Unit testing five_tests.cpp with g++ ✗
Skipping compilation of examples... as requested via command line
Failures: 1 |
Oh, I see. You are downloading Your cat > Gemfile << EOF
source 'https://rubygems.org'
gem 'arduino_ci', :path => "../arduino_ci" # note navigation to parent directory
EOF And the installation of arduino_ci should go like this: mkdir test
cat > test/five_tests.cpp << EOF
// blah blah blah
EOF
pushd ".." # note navigation to parent directory
git clone https://github.com/ianfixes/arduino_ci
cd arduino_ci
git am .../debug.patch # https://github.com/ianfixes/arduino_ci/issues/69#issuecomment-459180028
popd # now back in arduino library directory
bundle install --path vendor/bundle # can also use "--deployment" instead of this
bundle exec arduino_ci_remote.rb --skip-compilation Does that make sense? |
Thanks. This makes sense. I have now restructured my project to have its content in a subdirectory in parallel with the arduino_ci submodule and it now works fine using latest master version (with some of my additional changes). |
Note to self: add to #114 |
System
ruby -v
: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]bundle -v
: Bundler version 1.17.3bundle info arduino_ci
:g++ -v
:java -version
:openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
Issue Summary
I try to use arduino_ci as a unit test tool for local development, e.g. only on my machine, not in a github repo.
Something triggers arduino_ci to include some files twice, causing the compiler to fail because of duplicate definitions.
Arduino or Unit Test Code, Illustrating the Problem
I have created a minimal example to trigger this. Steps to reproduce:
Then running arduino_ci fails:
Breaking up the last command on separate lines makes it easy to see the duplicated files:
Arduino Architecture(s) Affected
Only tested for Uno, but I assume this is generic.
The text was updated successfully, but these errors were encountered: