Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,46 @@ make STAR CXXFLAGS_SIMD=sse
Compile under Mac OS X
----------------------

For Intel-based Macs:
```bash
# 1. Install brew (http://brew.sh/)
# 2. Install gcc with brew:
$ brew install gcc
# 3. Build STAR:
# run 'make' in the source directory
# note that the path to c++ executable has to be adjusted to its current version
$cd source
$make STARforMacStatic CXX=/usr/local/Cellar/gcc/8.2.0/bin/g++-8
# 4. Make it availible through the terminal
$cp STAR /usr/local/bin
$ cd source
$ make STARforMacStatic CXX=/usr/local/Cellar/gcc/8.2.0/bin/g++-8
# 4. Make it available through the terminal
$ cp STAR /usr/local/bin/
```

For Apple Silicon (M1/M2/M3) Macs:
```bash
# 1. Install brew (http://brew.sh/)
# 2. Install gcc:
brew install gcc

# 3. Find the gcc compiler path:
brew list gcc | grep c++-

# 4. Clone STAR repository:
git clone https://github.com/alexdobin/STAR.git
cd STAR/source/

# 5. Build STAR (adjust gcc version as needed):
make STARforMacStatic CXX=/opt/homebrew/Cellar/gcc/14.2.0_1/bin/c++-14

# 6. Verify compilation:
./STAR --version
./STAR --help

# 7. Make it available through the terminal
sudo cp STAR /usr/local/bin/

# 8. Verify installation:
which STAR
STAR --version
```

All platforms - non-standard gcc
Expand Down
2 changes: 1 addition & 1 deletion source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ all: cleanCompileInfo STAR$(SFX)

opal/opal.o : opal/opal.cpp opal/opal.h
cd opal && \
$(CXX) -c -I./ -std=c++11 $(CPPFLAGS) $(CXXFLAGS) $(CXXFLAGSextra) $(CXXFLAGS_SIMD) opal.cpp
$(CXX) -c -I./ -std=c++11 $(CPPFLAGS) $(CXXFLAGS) $(CXXFLAGSextra) opal.cpp

.PHONY: clean
clean:
Expand Down
61 changes: 44 additions & 17 deletions source/Parameters_openReadsFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include "ErrorWarning.h"
#include <fstream>
#include <sys/stat.h>
#include <spawn.h> // Add this for posix_spawn
#include <errno.h>

void Parameters::openReadsFiles()
{
if (readFilesCommandString=="") {//read from file
Expand Down Expand Up @@ -78,25 +81,49 @@ void Parameters::openReadsFiles()
chmod(readsCommandFileName.at(imate).c_str(),S_IXUSR | S_IRUSR | S_IWUSR);

readFilesCommandPID[imate]=0;

// Prepare spawn attributes and actions
posix_spawnattr_t attr;
posix_spawn_file_actions_t actions;

if (posix_spawnattr_init(&attr) != 0 ||
posix_spawn_file_actions_init(&actions) != 0) {
ostringstream errOut;
errOut << "EXITING: because of fatal EXECUTION error: Failed initializing spawn attributes\n";
errOut << errno << ": " << strerror(errno) << "\n";
exitWithError(errOut.str(), std::cerr, inOut->logMain, EXIT_CODE_PARAMETER, *this);
}

ostringstream errOut;
pid_t PID=vfork();
switch (PID) {
case -1:
errOut << "EXITING: because of fatal EXECUTION error: Failed vforking readFilesCommand\n";
errOut << errno << ": " << strerror(errno) << "\n";
exitWithError(errOut.str(), std::cerr, inOut->logMain, EXIT_CODE_PARAMETER, *this);
break;

case 0:
//this is the child
execlp(readsCommandFileName.at(imate).c_str(), readsCommandFileName.at(imate).c_str(), (char*) NULL);
exit(0);

default:
//this is the father, record PID of the children
readFilesCommandPID[imate]=PID;
// Prepare arguments
char* argv[] = {
const_cast<char*>(readsCommandFileName.at(imate).c_str()),
nullptr
};

// Spawn the process
pid_t PID;
int status = posix_spawn(
&PID,
readsCommandFileName.at(imate).c_str(),
&actions,
&attr,
argv,
nullptr // Use current environment
);

// Clean up spawn attributes and actions
posix_spawnattr_destroy(&attr);
posix_spawn_file_actions_destroy(&actions);

if (status != 0) {
ostringstream errOut;
errOut << "EXITING: because of fatal EXECUTION error: Failed spawning readFilesCommand\n";
errOut << errno << ": " << strerror(errno) << "\n";
exitWithError(errOut.str(), std::cerr, inOut->logMain, EXIT_CODE_PARAMETER, *this);
}

// Record the PID
readFilesCommandPID[imate] = PID;

inOut->readIn[imate].open(readFilesInTmp.at(imate).c_str());
};
Expand Down