mercredi 5 août 2020

Build fails on latest ubuntu in github actions with std::sort but passes without std::sort

I am trying to do something seemingly trivial: use the std::sort function on a std::vector<float>. The issue is one I can't seem to find an answer for. For reference, here is the first bit of the function I am using:

std::vector<std::string> MassDawg::search(std::vector<float> sequence, int ppmTol){
    MassDawgNode * currentNode = this->root;

    if (sequence.empty()) return std::vector<std::string> {};

    std::sort(sequence.begin(), sequence.end(), std::less<float>());

Note I have tried using this sort function without the std::less<float>() with the same issue.

This code runs perfectly on my MacBook pro (2016 13inch on macOS 10.15.5). It compiles and runs perfectly fine on my laptop using C++11. The problem comes with my push to github. I have an action setup as follows:

name: build and test

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    # Runs a set of commands using the runners shell
    - name: Build and test 
      run: |
        chmod u+x build_and_test_cc.sh
        echo Building and testing
        ./build_and_test_cc.sh
        echo Done

My the shell script ./build_and_test_cc is a small one that simply runs my makefile and and runs my unittests (I use catch.h).

Again, the problem only occurs AFTER I add the sort function. If I remove this line, it works fine. Here is my makefile.

# Variables 
CC = clang++
CFLAGS = -Wall -g -std=c++11

# Executable
main: main.o MassDawg.o MassDawgNode.o utils.o
    $(CC) $(CFLAGS) -o main main.o MassDawg.o MassDawgNode.o utils.o

test: test.o MassDawg.o MassDawgNode.o utils.o
    $(CC) $(CFLAGS) -o test test.o MassDawg.o MassDawgNode.o utils.o

# Object files
main.o: main.cpp MassDawg.hpp
    $(CC) $(CFLAGS) -c main.cpp

test.o: test.cpp MassDawg.hpp
    $(CC) $(CFLAGS) -c test.cpp

MassDawg.o: MassDawg.hpp MassDawgNode.hpp utils.hpp
    $(CC) $(CFLAGS) -c MassDawg.cpp 

MassDawgNode.o: MassDawgNode.hpp 
    $(CC) $(CFLAGS) -c MassDawgNode.cpp

utils.o: utils.hpp
    $(CC) $(CFLAGS) -c utils.cpp

clean:
    rm main test *.o

My strong suit is not makefiles, so it could very well be the problem. I am completely perplexed and have no idea what could be causing this. Thanks

Aucun commentaire:

Enregistrer un commentaire